Wayniac Posted February 2, 2010 Share Posted February 2, 2010 Hey all, I am trying to figure out what the best way for me to try and set up a max file size (ex: 150kb) for my image upload script. Here is an example of one of my previous attempts: list($size, $width, $height, $type, $html_string, $mime) = getimagesize($_FILES['imagefile']['tmp_name']); if ($size > 150000) { echo "Error: Image SIZE must be 150kb or less.<br>"; echo "<a href=\"javascript:history.back()\">Return to previous page.</a>"; exit(); } The code above is using a notation type of 1000. I also tried 1024 notation which was 153600 bytes (150kb). Neither of these worked properly. When I tried to upload a file that was 64kb, my error check popped up saying it was over 150kb. Is there something wrong with my code or the method I am approaching. Link to comment https://forums.phpfreaks.com/topic/190707-max-file-size-suggestions/ Share on other sites More sharing options...
akitchin Posted February 2, 2010 Share Posted February 2, 2010 getimagesize just gives you the dimensions of the image, not the filesize. the filesize is actually already present in the $_FILES[] array for the given file. have a look at the manual for handling file uploads: PHP Manual: POST method uploads Link to comment https://forums.phpfreaks.com/topic/190707-max-file-size-suggestions/#findComment-1005716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.