I'm working on a PHP site and I have a function that uploads the images. I did not do this site from scratch and I'm basically just tracing code that the other developer did. Here's the function:
Code: Select all
function imageUpload($uploaded_file)
{
echo "";
// check for a successfully uploaded image
if ($uploaded_file['error'] == UPLOAD_ERR_NO_FILE)
return null;
if ($uploaded_file['error'] != UPLOAD_ERR_OK)
return 'The image did not upload correctly. Please try reducing the size of the file before uploading.';
$src_fn = escapeshellarg($uploaded_file['tmp_name']);
// check the uploaded image is a supported mime type
$mime = exec("identify {$src_fn} 2>/dev/null");
if (!preg_match('/^.* (JPEG|PNG|GIF|TIFF) (\d+)x(\d+) /', $mime, $matches))
return 'The uploaded image is not a supported image format, please upload a JPEG, GIF, TIFF or PNG file.';
.
.
.
}
Code: Select all
exec("identify {$src_fn} 2>/dev/null");
The value of $uploaded_file are these:
$uploaded_file["name"] = "saveimageupload.jpg"
$uploaded_file["type"] = "image/pjpeg"
$uploaded_file["tmp_name"] = "image/pjpeg"
$uploaded_file["error"] = 0
$uploaded_file["size"] = 15327
I really don't know what the function "identify {} 2>/dev/null" does.
Thank you.