Link to home
Start Free TrialLog in
Avatar of zsadal
zsadal

asked on

Setting File filters

Hi
I have to upload files from a php/html site.
Is there ne way to set the file type filter in upload dialog to images only.
Avatar of Joakim_
Joakim_

You can use either JavaScript or PHP to check what the file exstension is. But don't ask me how.
ASKER CERTIFIED SOLUTION
Avatar of seanpowell
seanpowell
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
simple php solution, it wont filter it client side but will check server side

$allowed_files = array("image/gif","image/pjpeg","image/jpeg","image/jpg","images/png");

if (!in_array($_FILES['file_upload_form_field_name']['type'],$allowed_files)) {
  echo "this file type is not allowed";
 }
Are you talking about specifying hard-coded filters into <input type="file"...> ?
I think it is not possible, not my standard/pure HTML at least...