gatzkerob Posted May 27, 2011 Share Posted May 27, 2011 How on earth I'm supposed to use UPLOAD_ERR_INI_SIZE or UPLOAD_ERR_FORM_SIZE when $_FILES is empty due to an over-sized file? ie: echo $_FILES['file_upload']['error']; Will not work when the file is too large, rendering UPLOAD_ERR_INI_SIZE and UPLOAD_ERR_FORM_SIZE useless.. Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/ Share on other sites More sharing options...
The Little Guy Posted May 27, 2011 Share Posted May 27, 2011 You should be able to do something like this: if(move_uploaded_file($_FILES['file_upload']['temp_name'], 'files/'.$_FILES['file_upload']['name'])){ echo "File was uploaded"; }else{ echo "File was not uploaded"; } Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221168 Share on other sites More sharing options...
kumarkiranm Posted May 27, 2011 Share Posted May 27, 2011 I think u got it now Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221174 Share on other sites More sharing options...
gatzkerob Posted May 27, 2011 Author Share Posted May 27, 2011 You should be able to do something like this: if(move_uploaded_file($_FILES['file_upload']['temp_name'], 'files/'.$_FILES['file_upload']['name'])){ echo "File was uploaded"; }else{ echo "File was not uploaded"; } My point is, UPLOAD_ERR_INI_SIZE will never get used because an over-sized file will cause $_FILES to be an empty array. Bug, maybe? Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221179 Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2011 Share Posted May 27, 2011 @TLG, when validating user supplied data, it is important to tell the user exactly what was wrong with the data they supplied (as long as you are not exposing security related information). Just telling them that some data they supplied didn't work is a useless waste of bandwidth. Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221180 Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2011 Share Posted May 27, 2011 The quote I posted in your other thread on this subject, is directly out of the post_max_size documentation. It's not a bug, its the defined response that php takes - If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221181 Share on other sites More sharing options...
gatzkerob Posted May 27, 2011 Author Share Posted May 27, 2011 The quote I posted in your other thread on this subject, is directly out of the post_max_size documentation. It's not a bug, its the defined response that php takes - If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. Yea, I get that. I just think it's odd that they created UPLOAD_ERR_INI_SIZE when it can never be used. Also, is an over-sized file the only thing that can cause $_FILES and $_POST to be empty? Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221186 Share on other sites More sharing options...
The Little Guy Posted May 27, 2011 Share Posted May 27, 2011 Just telling them that some data they supplied didn't work is a useless waste of bandwidth. Well that will say that the file didn't upload. I am not sure if this is related, but apache processes the upload by putting it in the tmp folder, then php moves it to the proper location on the server for better accessibility via web browser. Quote Link to comment https://forums.phpfreaks.com/topic/237646-how-on-earth/#findComment-1221202 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.