?
Solved

Setting File filters

Posted on 2004-08-12
6
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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