Uploading files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux