Solved

Setting File filters

Posted on 2004-08-12
6
154 Views
Last Modified: 2010-04-09
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
Comment
Question by:zsadal
6 Comments
 
LVL 2

Expert Comment

by:Joakim_
ID: 11782467
You can use either JavaScript or PHP to check what the file exstension is. But don't ask me how.
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 25 total points
ID: 11782499
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11784281
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
 
LVL 3

Expert Comment

by:Boris Aranovich
ID: 11840484
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question