Uploading files?

From: Date: Thu, 19 May 2005 11:46:48 +0000
Subject: Uploading files?
Groups: php.general 
Request: Send a blank email to php-general+get-215582@lists.php.net to get a copy of this message
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.

« previous php.general (#215582) next »