You are here: Uploading files? « PHP « IT news, forums, messages
Uploading files?

Posted by rory walsh on 10/14/08 11:16

Hi list, I am having a little problem with the code below. It just won't
seem to work? Even though I always select a jpeg my mime content type
test is never true? Have I made a silly mistake somewhere? I also run
the test to see if the 'mime_content_type()' function exists first
before I do any checking.


$uploaddir = 'Uploads/';
$basename = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (!function_exists('mime_content_type')) {
function mime_content_type($f) {
$f = escapeshellarg($f);
return trim( `file -bi $f` );
}
}


if(mime_content_type($uploadfile)=="image/jpeg")
{
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
$_SESSION['UPLOAD_STRING'] = "\"".$basename."\""." is a valid
file type and was successfully uploaded.";
}
else if(strlen($basename)<1)
{
$_SESSION['UPLOAD_STRING'] = "No file specified, please try again";
}
}
else $_SESSION['UPLOAD_STRING'] = "File extension not supported, please
make sure you use a valid extension.";


Cheers,
Rory.

 

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

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