Jump to content

How to restrict file type


AGazzaz
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...