Hi all, i have 3 upload forms and a script to check mime types to make sure uploaded files are images.
//check picture1 MIME type
if (!in_array($picture1_type, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png')))
{
$picture1_error = TRUE;
echo 'Problem: File must be an image';
exit();
} else {
$picture1_error = FALSE;
echo $picture1_name.' uploaded successfully<br/>';
}
//check picture2 MIME type
if (!in_array($picture1_type, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png')))
{
$picture2_error = TRUE;
echo 'Problem: File must be an image';
exit();
} else {
$picture2_error = FALSE;
echo $picture2_name.' uploaded successfully<br/>';
}
//check picture3 MIME type
if (!in_array($picture1_type, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png')))
{
$picture3_error = TRUE;
echo 'Problem: File must be an image';
exit();
} else {
$picture3_error = FALSE;
echo $picture3_name.' uploaded successfully<br/>';
}
Problem is that, if the user only wishes to upload 1 file or upload no files at all, the exit command will stop the whole script. Is there any way around this? I want users to have the option of uploading nothing at all if they do not want to.