|
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]
|