Q695 Posted April 30, 2013 Share Posted April 30, 2013 Why does a blank file input upload a blank file slot, and not NULL array item if submitting it when blank, and how do you overcome that issue? Link to comment https://forums.phpfreaks.com/topic/277470-odity-of-_files/ Share on other sites More sharing options...
akphidelt2007 Posted April 30, 2013 Share Posted April 30, 2013 You can get it by the error message. 4 means that no file was submitted. So if($_FILES['myfile']['error']==4) { echo 'No file has been submitted'; } You can view a list of the error types here... http://php.net/manual/en/features.file-upload.errors.php Link to comment https://forums.phpfreaks.com/topic/277470-odity-of-_files/#findComment-1427376 Share on other sites More sharing options...
ignace Posted May 1, 2013 Share Posted May 1, 2013 It's better to use the constant instead of 4 since if they ever change it you need to update all your code: if ($_FILES['upload']['error'] === UPLOAD_ERR_NO_FILE) Link to comment https://forums.phpfreaks.com/topic/277470-odity-of-_files/#findComment-1427467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.