You are here: Re: [PHP] filtering uploaded files « PHP « IT news, forums, messages
Re: [PHP] filtering uploaded files

Posted by A. S. Milnes on 03/29/05 21:13

On Tue, 2005-03-29 at 21:59, Cima wrote:
> hi,
>
> id like to know if there is a way to filter or specify what type of files id like uploaded to my server. for example, if i make a form to upload image files, when i click browse there are 2 fields one that'll store the file name(of the file selected) and the other filetype (usually say all types) what id like is to specify in file type : *.jpg,*gif etc. is this possible?

Here's an snippet that should help you on the way - although people can
fool about with filetypes so be careful.

//The mime type of the file, if the browser provided this information.
$userfile_type=$_FILES['userfile']['type'];

switch ($userfile_type)
{
case "text/x-csv" :
echo "<br />\n<p>File is in CSV format.........</p>";
break;

default : // code to do something;
echo "\n<p>Problem: file is not in correct format.</p>";
exit;
}


Alan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация