gerkintrigg Posted October 25, 2007 Share Posted October 25, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/ Share on other sites More sharing options...
BlueSkyIS Posted October 25, 2007 Share Posted October 25, 2007 what do you think is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/#findComment-378189 Share on other sites More sharing options...
bigdspbandj Posted October 25, 2007 Share Posted October 25, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/#findComment-378211 Share on other sites More sharing options...
teng84 Posted October 25, 2007 Share Posted October 25, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/#findComment-378244 Share on other sites More sharing options...
gerkintrigg Posted October 26, 2007 Author Share Posted October 26, 2007 you missed the S from FILES but this works : if($_FILES['imagefile']['error']==4) { $go=$root.'includes/enter_details_bypass_image_upload.php'; header('Location:'.$go); } Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/74792-checking-file-upload-isnt-empty/#findComment-378490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.