AGazzaz Posted October 27, 2007 Share Posted October 27, 2007 HelloI have a form and I want to restrict users choice to images only but the following code is not working. What could be the problem? <form> <p align="center"> Photo to upload: <input type="submit" accept="image/*" name="photo" /> </p></form> Link to comment Share on other sites More sharing options...
boen_robot Posted October 27, 2007 Share Posted October 27, 2007 Shouldn't this be set on the file input field itself, i.e. <form> <p align="center"> Photo to upload: <input type="file" accept="image/*" name="photo" /> </p> <input type="submit"/></form> Link to comment Share on other sites More sharing options...
jlhaslip Posted October 27, 2007 Share Posted October 27, 2007 Probably better to create a list of acceptable image types to check against in a function using php scripting (or js) rather than use a 'wildcard' Link to comment Share on other sites More sharing options...
boen_robot Posted October 27, 2007 Share Posted October 27, 2007 Probably better to create a list of acceptable image types to check against in a function using php scripting (or js) rather than use a 'wildcard'Yeah. Such check should be made anyways, since the request could be forged, so someone may send any file, regardless of what you have specified.In addition, I just tryed that, and it seems Opera is the only browsers that even regards the "accept" attribute to begin with. So, if you want, keep it as I've shown it, but yes, also make a server side check, and on the form, inform the user the file must be an image, whitelisting the actual accepted MIME types (or better yet - the extensions). Link to comment Share on other sites More sharing options...
jlhaslip Posted October 27, 2007 Share Posted October 27, 2007 And as an additional note, be sure to check for upper + lower case extensions. (gif != GIF) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.