How to restrcit selections of files for upload - client / browser side?
The attribute accept="image/jpeg" doesn't seem to have any effect in file tag of HTML.
Note: I am using HTML and PHP only and am not familiar with Ajax or any other such tools. I want users to be able to browse and select only image (.jpg) files.
Restrict File Types for Upload
Moderator: General Moderators
Re: Restrict File Types for Upload
http://www.webcheatsheet.com/PHP/file_upload.php
you restrict using the type property
$_FILES["uploaded_file"]["type"]
you restrict using the type property
$_FILES["uploaded_file"]["type"]
Re: Restrict File Types for Upload
I don't know of any browser that honors the accept property.
Also, using $_FILES[...]["type"] is very risky. It's supplied by the browser which means a malicious user could fake it.
Figure out the file type yourself. For images you can use getimagesize; for others you can make something yourself or use the fileinfo extension.
Also, using $_FILES[...]["type"] is very risky. It's supplied by the browser which means a malicious user could fake it.
Figure out the file type yourself. For images you can use getimagesize; for others you can make something yourself or use the fileinfo extension.