Jump to content

How to restrict file type

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...