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? Quote 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 Quote 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) Quote Link to comment https://forums.phpfreaks.com/topic/277470-odity-of-_files/#findComment-1427467 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.