BarneyJoe Posted April 5, 2007 Share Posted April 5, 2007 Hope someone can help with this. Have a file upload script that all seemed to be working fine, using the PHP component that resizes images (forget it's name). So it checks the file name is unique, checks it's a jpg, gif, bmp or photoshop file as requires, and has a max file size line to limit it's size. However, it seems that with any file over around 2MB, it's not uploading, and we're getting the error about it not being a jpg or gif. The line in the upload page is : <input name="uploadFile" type="file" size="55"> <input type="hidden" name="MAX_FILE_SIZE" value="80000" /> It did have a default value of 25000 but I changed it to 80000, but still the same problem. Some code from the validation page : $ValidationFailed = false; if (($_FILES["uploadFile"]["type"] == "image/gif") || ($_FILES["uploadFile"]["type"] == "image/pjpeg") || ($_FILES["uploadFile"]["type"] == "image/tif") || ($_FILES["uploadFile"]["type"] == "image/png") || ($_FILES["uploadFile"]["type"] == "image/photoshop") || ($_FILES["uploadFile"]["type"] == "image/bmp")) { if ($_FILES["uploadFile"]["error"] > 0) { $ValidationFailed = true; $FTGvalid_file_errmsg = "Error: " . $_FILES["file"]["error"]; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } } else { $ValidationFailed = true; $FTGvalid_file_errmsg = "Please select a valid image file type. The library supports .jpg, .gif, and .png files."; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } if (!empty($_FILES['uploadFile']['name']) && file_exists("Photos/" . $_FILES["uploadFile"]["name"]) && is_file('Photos/' . $_FILES['uploadFile']['name'])) { $ValidationFailed = true; $FTGvalid_file_errmsg = "This file has already been uploaded. If you are sure it's a new photo please rename it before uploading to the library."; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/ Share on other sites More sharing options...
MadTechie Posted April 5, 2007 Share Posted April 5, 2007 find upload_max_filesize in your php.ini file and change it Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221925 Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 Not sure but try ini_get('upload_max_filesize',10000000); Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221930 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 Cheers guys - I found the upload_max_filesize in php.ini, and sure enough it was 2M - I changed it to 8M, but still getting the 'Please select a valid image file type. The library supports .jpg, .gif, and .png files.' error message. Where should I try the ini_get('upload_max_filesize',10000000); line - the addphoto page, or the validation script? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221938 Share on other sites More sharing options...
$cripts Posted April 5, 2007 Share Posted April 5, 2007 put it in the uploader script it will change the maximum upload size in the php.ini file and it will be ini_set('upload_max_filesize',whateversizeinbytes); it will need to be in the upload script because once the script is done executing it will reset back to its default value Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221939 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 Anywhere in particular in relation to the code I posted originally? I tried it in a couple of places, and it's giving me the following error : Warning: Wrong parameter count for ini_get() in C:\wamp\www\Photolibrary\validation.php on line 304 Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221947 Share on other sites More sharing options...
$cripts Posted April 5, 2007 Share Posted April 5, 2007 because ini_get will only retrieve the value of a php setting ini_get(setting_name); u need to use ini_set(setting_name,value); Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221949 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 OK - didn't spot that set instead of get there. I popped it in at the top of that part, ie : # Fields Validations ini_set('upload_max_filesize',10000000); $ValidationFailed = false; if (($_FILES["uploadFile"]["type"] == "image/gif") || ($_FILES["uploadFile"]["type"] == "image/pjpeg") || ($_FILES["uploadFile"]["type"] == "image/tif") || ($_FILES["uploadFile"]["type"] == "image/png") || ($_FILES["uploadFile"]["type"] == "image/photoshop") || ($_FILES["uploadFile"]["type"] == "image/bmp")) { if ($_FILES["uploadFile"]["error"] > 0) { $ValidationFailed = true; $FTGvalid_file_errmsg = "Error: " . $_FILES["file"]["error"]; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } } else { $ValidationFailed = true; $FTGvalid_file_errmsg = "Please select a valid image file type. The library supports .jpg, .gif, and .png files."; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } if (!empty($_FILES['uploadFile']['name']) && file_exists("Photos/" . $_FILES["uploadFile"]["name"]) && is_file('Photos/' . $_FILES['uploadFile']['name'])) { $ValidationFailed = true; $FTGvalid_file_errmsg = "This file has already been uploaded. If you are sure it's a new photo please rename it before uploading to the library."; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } ...but still getting the Please select a valid image file type. The library supports .jpg, .gif, and .png files. error. Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221959 Share on other sites More sharing options...
MadTechie Posted April 5, 2007 Share Posted April 5, 2007 add print_r($_FILES["uploadFile"]["type"]); after the $ValidationFailed = false; whats the result ? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221962 Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 Where should I try the ini_get('upload_max_filesize',10000000); - At biggining of file where upload script is written. Cheers guys - I found the upload_max_filesize in php.ini, and sure enough it was 2M - I changed it to 8M, but still getting the 'Please select a valid image file type. The library supports .jpg, .gif, and .png files.' error message. Where should I try the ini_get('upload_max_filesize',10000000); line - the addphoto page, or the validation script? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221971 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 Just the same, with no output - so not seeing the file type for some reason. If I try a file < 2MB it's fine, and correctly displays : image/pjpeg Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221977 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 ini_get('upload_max_filesize',10000000); - At biggining of file where upload script is written. OK - added it in there, out of the way, and still no joy, still with images over 2MB..... Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221983 Share on other sites More sharing options...
MadTechie Posted April 5, 2007 Share Posted April 5, 2007 change if (($_FILES["uploadFile"]["type"] == "image/gif") || ($_FILES["uploadFile"]["type"] == "image/pjpeg") || ($_FILES["uploadFile"]["type"] == "image/tif") || ($_FILES["uploadFile"]["type"] == "image/png") || ($_FILES["uploadFile"]["type"] == "image/photoshop") || ($_FILES["uploadFile"]["type"] == "image/bmp")) { to if (($_FILES["uploadFile"]["type"] == "image/gif") || ($_FILES["uploadFile"]["type"] == "image/pjpeg") || ($_FILES["uploadFile"]["type"] == "image/tif") || ($_FILES["uploadFile"]["type"] == "image/png") || ($_FILES["uploadFile"]["type"] == "image/photoshop") || ($_FILES["uploadFile"]["type"] == "image/bmp")) || ($_FILES["uploadFile"]["type"] == "image/pjpeg")) { Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-221987 Share on other sites More sharing options...
BarneyJoe Posted April 5, 2007 Author Share Posted April 5, 2007 Nope Things are never straightforward, are they? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-222009 Share on other sites More sharing options...
BarneyJoe Posted April 10, 2007 Author Share Posted April 10, 2007 Just having a look at this again this morning, and added in a phpinfo (); Which is correctly listing the max file upload size as 8M, so I'm pretty stuck now. It's still bringing up my 'Please select a valid image file type. The library supports .jpg, .gif, and .png files.' So it's not OK for jpgs >2M, even tho' the max file size is set to 8M, and it is fine for jpgs < 2M. Any more ideas.....? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225631 Share on other sites More sharing options...
MadTechie Posted April 10, 2007 Share Posted April 10, 2007 that message will appear on almost every error so try to workout what the real problem is try print_r($_FILES["uploadFile"]; Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225648 Share on other sites More sharing options...
BarneyJoe Posted April 10, 2007 Author Share Posted April 10, 2007 OK - tried that with a file > 2MB, and got the output : Array ( [name] => DSC00023.JPG [type] => [tmp_name] => [error] => 1 => 0 ) Tried it with a file <2MB, and got the output : Array ( [name] => A8DTRE.jpg [type] => image/pjpeg [tmp_name] => c:/wamp/tmp\php28D0.tmp [error] => 0 => 39168 ) So in the first one, for some reason it didn't seem to recognise the file type, as the 'image/pjpeg' was missing? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225662 Share on other sites More sharing options...
BarneyJoe Posted April 10, 2007 Author Share Posted April 10, 2007 Just spotted that the upload_max_filesize is still showing as 2M in phpinfo(), even tho' I've changed it to 8M in the php.ini file, and added <?php ini_set('upload_max_filesize', '8M'); ?> to the top of the page with the upload script. I changed the post_max_size to 9M in the php.ini, but it's still showing as 8M in the phpinfo() too. What could be stopping this from taking effect, if it's changed in the php.ini file, and forced using ini_set? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225722 Share on other sites More sharing options...
MadTechie Posted April 10, 2007 Share Posted April 10, 2007 erm.. a reboot maybe:p Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225729 Share on other sites More sharing options...
BarneyJoe Posted April 10, 2007 Author Share Posted April 10, 2007 The old, tried and tested, try switching it off, and then back on again trick? Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225733 Share on other sites More sharing options...
BarneyJoe Posted April 10, 2007 Author Share Posted April 10, 2007 OK - stop the clock. Stopping and restarting the Apache server did the trick. Thanks for the patience! Quote Link to comment https://forums.phpfreaks.com/topic/45687-solved-file-upload-help-max-file-size/#findComment-225739 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.