Jump to content

Max File Size For Uploads


son
 Share

Recommended Posts

I have set a photo upload form to a maximum size of 0.5 MB. The user now tried to upload lots of photos that are 2 or 3Mb, so I am not sure if it would be a good option to increase the allowed file size. On the other hand as I am running scripts to establish the correct width and/or height I do not want the user to have to go into PHotoshop to reduce file size before being able to upload photos. What would you set as a maximum file size for uploading photos?Son

Link to comment
Share on other sites

Maybe searching like something below? It filters executable files, files that exceed filesize, and foto's that are larger than the given width or height. Just copy and paste the stuff that you want to use for your own script

<?php// check for uploaded file sizeif ($_FILES['imagefile']['size'] > 50000 ){die ("ERROR: Large File Size");}//check if its image fileif (!getimagesize($_FILES['imagefile']['tmp_name'])){ echo "Invalid Image File...";exit();}// restrict width and height if its image or photo filelist($width, $height, $type, $attr) = getimagesize($_FILES['imagefile']['tmp_name']);if ($width > 100 || $height > 100){echo "Maximum width and height exceeded. Please upload images below 100x100 px size";exit();}$blacklist = array(".php", ".phtml", ".php3", ".php4", ".js", ".shtml", ".pl" ,".py");foreach ($blacklist as $file){if(preg_match("/$file\$/i", $_FILES['userfile']['name'])){echo "ERROR: Uploading executable files Not Allowed\n";exit;}}

Link to comment
Share on other sites

Maybe searching like something below? It filters executable files, files that exceed filesize, and foto's that are larger than the given width or height. Just copy and paste the stuff that you want to use for your own script
<?php// check for uploaded file sizeif ($_FILES['imagefile']['size'] > 50000 ){die ("ERROR: Large File Size");}//check if its image fileif (!getimagesize($_FILES['imagefile']['tmp_name'])){ echo "Invalid Image File...";exit();}// restrict width and height if its image or photo filelist($width, $height, $type, $attr) = getimagesize($_FILES['imagefile']['tmp_name']);if ($width > 100 || $height > 100){echo "Maximum width and height exceeded. Please upload images below 100x100 px size";exit();}$blacklist = array(".php", ".phtml", ".php3", ".php4", ".js", ".shtml", ".pl" ,".py");foreach ($blacklist as $file){if(preg_match("/$file\$/i", $_FILES['userfile']['name'])){echo "ERROR: Uploading executable files Not Allowed\n";exit;}}

Thanks for your reply. I have scripts in place to resize and all that. IT is just that I added:<input type="hidden" name="MAX_FILE_SIZE" value="524288" />to form and wondered if I can increase the size without running into major issues... ANy ideas on that?Son
Link to comment
Share on other sites

Best to check the maximum memory limit you have set for your server, if you start playing with larger images you can run into problems quickly.
As it is a hosted account, will have to check with Hosting company...Many thanks,Son
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...