valoukh Posted June 17, 2009 Share Posted June 17, 2009 Hi all, I can't seem to upload files larger that 300kb on my site. I've checked the phpinfo() page: upload_max_filesize = 2M post_max_size = 8M I don't have access to change php.ini so I edited ".htaccess" and added this line: php_value upload_max_filesize 10M Still not working. It let's me upload anything less than 300kb, but I could do with more like 3mb! If anyone has any ideas it'd be much appreciated. Thanks, valoukh Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 17, 2009 Share Posted June 17, 2009 If phpinfo() shows that those two values are much larger than the file size that fails, your problem is something else. Post your form and your form processing code. Quote Link to comment Share on other sites More sharing options...
valoukh Posted June 17, 2009 Author Share Posted June 17, 2009 Hey, thanks for your reply. Here goes: FORM: <form enctype="multipart/form-data" action="upload_up.php" method="POST"> Choose file: <input name="uploaded" type="file"> <input type="submit" value="Upload"> </form> PROCESS: <?php $uploadedfile = $_FILES['uploaded']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=250; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); if ($width > 250) { imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); } $filename = "uploads/". $_FILES['uploaded']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $filename)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br>"; } else{ echo "There was an error uploading the file, please try again!<br>"; } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 17, 2009 Share Posted June 17, 2009 You are likely getting a fatal runtime error in the GD functions. Add the following two sections of code immediately after your first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL); echo "<pre>"; echo "FILES:"; print_r($_FILES); echo "</pre>"; Quote Link to comment Share on other sites More sharing options...
pkedpker Posted June 17, 2009 Share Posted June 17, 2009 I have no idea how ".htaccess" has any access to php.ini upload_max_filesize.. you will have to use php script to access php.ini meaning like http://www.google.com/search?hl=en&safe=off&rlz=1C1CHMG_en-US___US311&q=100+megabytes+to+bytes&aq=f&oq=&aqi= 100 megabytes = 104 857 600 bytes More about calculator. iniset('upload_max_filesize', 104857600); Quote Link to comment Share on other sites More sharing options...
valoukh Posted June 18, 2009 Author Share Posted June 18, 2009 PFMaBiSmAd: Here's what I get: Image of 700k: FILES:Array ( [uploaded] => Array ( [name] => test1.bmp [type] => [tmp_name] => [error] => 2 [size] => 0 ) ) Image of 100k: FILES:Array ( [uploaded] => Array ( [name] => test2.jpg [type] => image/jpeg [tmp_name] => /tmp/phpXr9rGB [error] => 0 [size] => 109109 ) ) pkedpker: I got the error "call to undefined function: iniset()", I changed it to "ini_set" and now get the error above. It's not the format as I've also tested with large JPGs. Thanks for your help so far guys. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 18, 2009 Share Posted June 18, 2009 [error] => 2 http://us3.php.net/manual/en/features.file-upload.errors.php Your code is not bothering to test for and report upload errors before blindly attempting to access nonexistent uploaded file information. For that specific error number, you have a setting in your form code that you are exceeding, and the form code you posted is not the form code you are actually using. Quote Link to comment Share on other sites More sharing options...
valoukh Posted June 22, 2009 Author Share Posted June 22, 2009 Yes - I cleared the html from the form to make it clearer but must have removed this accidentally: <input type="hidden" name="MAX_FILE_SIZE" value="300000"> However I played with this a lot before I even posted here: changing the value does nothing at all, and removing it did nothing either - but what I didn't realise is removing it gives a different error, 1 instead of 2. So it's failing at php.ini upload_max_filesize (the file I just tried was 7mb, in .htaccess I wrote "php_value upload_max_filesize 10M" but it doesn't seem to be working) thanks Quote Link to comment Share on other sites More sharing options...
valoukh Posted June 29, 2009 Author Share Posted June 29, 2009 still struggling with this, if anyone has any ideas! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 29, 2009 Share Posted June 29, 2009 What is the upload ['error'] number? What does a phpinfo(); statement show for upload_max_filesize now that you have tried to put the setting in to the .htaccess file? Quote Link to comment Share on other sites More sharing options...
valoukh Posted June 30, 2009 Author Share Posted June 30, 2009 the error number is 1, if you mean this bit: FILES:Array ( [uploaded] => Array ( [name] => bday_special_100%.jpg [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) And "upload_max_filesize" seems to say "2M" regardless of the .htaccess file.. :S thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 30, 2009 Share Posted June 30, 2009 And "upload_max_filesize" seems to say "2M" regardless of the .htaccess file.. :S That would indicate that the host either does not permit you to change the value or that it does not permit you to change it using a .htaccess file. You should be asking your host if or how you can change it on their servers. Quote Link to comment 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.