j.smith1981 Posted October 20, 2011 Share Posted October 20, 2011 When you try and upload files using a size limiting feature, when you consider $_FILES['form_element']['size'] what actually is this measured in again? I seem to have forgotten what it's actually measured in, if I was to say a limit on $_FILES['myform_file_upload']['size'] < 20000, what does the 20000 actually mean? Any help is appreciated, Jeremy. Quote Link to comment https://forums.phpfreaks.com/topic/249460-_filesnamesize-enquiry/ Share on other sites More sharing options...
AyKay47 Posted October 20, 2011 Share Posted October 20, 2011 the file size is measured in bytes. Quote Link to comment https://forums.phpfreaks.com/topic/249460-_filesnamesize-enquiry/#findComment-1280829 Share on other sites More sharing options...
j.smith1981 Posted October 20, 2011 Author Share Posted October 20, 2011 Oh of course, how would you then make it so that if say it was above 2mb big, how would you say the file was whatever the size of it was? How would you make it so it's more readable than just saying say 2000kbytes? So when a first comma should be in there, but making that like 2mb just as a bare example? Just something out of pure interest. Thank you though for clearing that up for me! Jeremy. Quote Link to comment https://forums.phpfreaks.com/topic/249460-_filesnamesize-enquiry/#findComment-1280832 Share on other sites More sharing options...
AyKay47 Posted October 20, 2011 Share Posted October 20, 2011 1. starter code here.. you will need to add to this $errors = array(); if($_FILES['image']['size'] > 2097152){ $errors[] = "File is too large, 2MB is the maximum file size."; } you would then display your $errors variable if an error has occurred. 2. don't fully understand your second question, but i think you want something like this.. $megabyte = 1048576; // bytes in megabyte $bytes = $_FILES['image']['size']; $total_megabytes = $bytes / $megabyte; Quote Link to comment https://forums.phpfreaks.com/topic/249460-_filesnamesize-enquiry/#findComment-1280836 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.