garry Posted June 1, 2008 Share Posted June 1, 2008 So i'm using some user supplied info from a form and the form contains a place where the user can specify an image file to be uploaded. This works fine when the image file is actually chosen, but if they do not select the image file, i don't want the script to use any of the image variables or anything, which is why I have the following code: if (isset($HTTP_POST_FILES['image']) && !empty($HTTP_POST_FILES['image'])) { // Check if image has been uploaded And also, I'm just using <input name="image" type="file" /> inside the actual form. But for some reason, when no file is uploaded, it still tries to do the things inside my if statement Can anyone help? Link to comment https://forums.phpfreaks.com/topic/108207-if-statement-not-working/ Share on other sites More sharing options...
DarkerAngel Posted June 1, 2008 Share Posted June 1, 2008 try if($HTTP_POST_FILES['image']['size'] > 0) ??? or if($HTTP_POST_FILES['image']['error'] == 4) Link to comment https://forums.phpfreaks.com/topic/108207-if-statement-not-working/#findComment-554648 Share on other sites More sharing options...
garry Posted June 1, 2008 Author Share Posted June 1, 2008 That did the trick, thanks Link to comment https://forums.phpfreaks.com/topic/108207-if-statement-not-working/#findComment-554649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.