disable or fix fileupload validation
I need the accept attribute to be since it's the only attribute combination that gives mobile devices an option to either click a photo, or choose one from files/documents (which is exactly what I need). But when I do that, I can't upload any images as it gives me error : file of invalid type. How can I fix this?
code:
Solution:Jump to solution
Yes, I understood.
capture="environment"
says: Use the camera. So you only get camera option.
<input type=“file” accept=“image/*;capture=camera”>
...15 Replies
bump
Capture is a separate attribute and not part of
accept
, right?MDN Web Docs
HTML attribute: capture - HTML: HyperText Markup Language | MDN
The capture attribute specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept attribute.
it is a separate attribute, and not part of accept in the documentation. But when I use it as a separate attribute, it only gives option to click a picture on mobile devices. when used as a part of accept as the way I did, it gives option to either choose an existing picture or click one with camera
But when I use it as a separate attribute, it only gives option to click a picture on mobile devicesClick a picture = Take one with the camera? That's what your code says
capture=camera
But when I use it as a separate attribute, it only gives option to click a picture on mobile devicesIsn't that the default? Btw. checking MDN again, there is no
capture=camera
valuei think I didn't explain it properly
there are 2 ways to upload an image
1) Pick from file manager
2) Click one from camera
Gives both option 1 & 2
if I use
Gives only option 2
I want both options
you're right, it isn't mentioned anywhere in the docs, I found it in a stackoverflow solution. But it's the only way I found that gives both options
Solution
Yes, I understood.
capture="environment"
says: Use the camera. So you only get camera option.
<input type=“file” accept=“image/*;capture=camera”>
Is an invalid accept value and an empty capture
.
So just omit capture
?What happens with:
<input type=“file” accept=“image/*”>
?only option 1, no choice for option 2
So just omit capture?if I omit capture it wouldn't give me options
Hm. That's weird. Maybe because of the
image/*
type?
But that should be okay tooi think it probably has something to do with how filament checks for file type/mimes with accept values (maybe it doesn't split the string properly, as it wouldn't expect ; in attribute value)
i tried to look up if there's any way I can disable client side validation, and couldn't find it either
Shouldn't this disable it?
->extraInputAttributes(['accept' => '*'])
doesn't work either
nvm, just removed the field, final code :