son Posted January 11, 2010 Share Posted January 11, 2010 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 More sharing options...
Redroest Posted January 11, 2010 Share Posted January 11, 2010 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 More sharing options...
son Posted January 11, 2010 Author Share Posted January 11, 2010 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 More sharing options...
justsomeguy Posted January 11, 2010 Share Posted January 11, 2010 What issues do you mean? There's a hard limit for the max size in either php.ini or an htaccess file, so that's as high as you can go in your script. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted January 11, 2010 Share Posted January 11, 2010 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. Link to comment Share on other sites More sharing options...
son Posted January 12, 2010 Author Share Posted January 12, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.