• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

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.
0
zsadal
Asked:
zsadal
1 Solution
 
Joakim_Commented:
You can use either JavaScript or PHP to check what the file exstension is. But don't ask me how.
0
 
seanpowellCommented:
Hi zsadal,

You should be able to handle this with some basic javascript. Here's a good write up that explains the process and limitations:

Filtering (through a file type filter)
http://www.cs.tut.fi/~jkorpela/forms/file.html#filter

Thanks,
Sean
0
 
Diablo84Commented:
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";
 }
0
 
Boris AranovichCommented:
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...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now