Jump to content

checking file upload isn't empty


gerkintrigg

Recommended Posts

Hi. I'm trying to check that a form has been filled in, but that the image field is NOT empty. I'm using this code:

 

if ((!isset($_FILES['imagefile']))&&($_POST['a']=='a')){
$go=$root.'includes/enter_details_bypass_image_upload.php';
header('Location:'.$go);
}

 

I think it's wrong and don't know how to fix it.

 

Any ideas?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/
Share on other sites

If you want to check if a file upload field is empty on submission you can check it's error code (error 4 code means that no file was provided):

 


if(array_key_exists($_FILE) {
   if($_FILE['file_field_name']['error'] == 4) {
     //set validation code
   }
}

 

 

Correct me if I am wrong.

 

 

Hi. I'm trying to check that a form has been filled in, but that the image field is NOT empty. I'm using this code:

 

if ((!isset($_FILES['imagefile']))&&($_POST['a']=='a')){
$go=$root.'includes/enter_details_bypass_image_upload.php';
header('Location:'.$go);
}

 

I think it's wrong and don't know how to fix it.

 

Any ideas?

 

Thanks in advance.

 

whats wrong?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.