I have an html form with some text and file inputs that submits to a PHP page. I want to error check the image file input but only if they choose to include one. Is there a way to check if there's an uploaded image file? I included my attempt below but it doesn't seem to be working.
if ($_FILES['image'])
{
if ($_FILES['image']['error'] > 0)
{
echo 'Problem: '; }}
switch ($_FILES['image']['error'])
{
case 1: echo 'File exceeded upload_max_filesize.';
break;
case 2: echo 'File exceeded max_file_size.';
break:
case 3: echo 'File only partially uploaded.';
break;
case 4: echo 'No file uploaded.';
break;
default: echo 'cannot upload.';
break;
}
exit;
}
}
Aucun commentaire:
Enregistrer un commentaire