Jump to content

php max upload size


valoukh

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/
Share on other sites

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>";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-858355
Share on other sites

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>";

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-858365
Share on other sites

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);

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-858374
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-858837
Share on other sites

[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.

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-859032
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-861122
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-866218
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/162621-php-max-upload-size/#findComment-866313
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.