UPload problem $20 reward for the answer
Moderator: General Moderators
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
UPload problem $20 reward for the answer
Ok. I have an upload script that was only allowing me to upload files in the several hundred byte range even though the upload_max_filesize in php.ini is set at 2M.
So I moved all the files to a new server. Now I am limited to anything over 450KB. Again the value in php.ini is set at 2M.
Can anyone tell me what server configuration is causing this problem
it is almost like a tmp copy of the image isn't getting copied to the server with the larger images because I get an error:
Warning: getimagesize: Unable to open '' for reading. in /home/public_html/uploadimage.php on line 75
The same picture, same name, same dimensions brought into PhotoShop and saved with a lower quality rating will upload no problem.
When I:
print_r($_POST);
print_r($_FILES);
I Get:
( [MAX_FILE_SIZE] => 8000000 [Submit] => Submit Picture ) Array ( [myfile] => Array ( [name] => myfile3.jpg [type] => image/pjpeg [tmp_name] => /tmp/php8SdQOI [error] => 0 [size] => 436817 ) )
This is with a file that works. When I throw a file of size 835213 at it both arrays are empty.
OS is linux, apache server. Upload works fine wiht anything under 450KB so i dont see it as a coding issue as much as a server config issue. I just need to track down the culprit causing this.
So I moved all the files to a new server. Now I am limited to anything over 450KB. Again the value in php.ini is set at 2M.
Can anyone tell me what server configuration is causing this problem
it is almost like a tmp copy of the image isn't getting copied to the server with the larger images because I get an error:
Warning: getimagesize: Unable to open '' for reading. in /home/public_html/uploadimage.php on line 75
The same picture, same name, same dimensions brought into PhotoShop and saved with a lower quality rating will upload no problem.
When I:
print_r($_POST);
print_r($_FILES);
I Get:
( [MAX_FILE_SIZE] => 8000000 [Submit] => Submit Picture ) Array ( [myfile] => Array ( [name] => myfile3.jpg [type] => image/pjpeg [tmp_name] => /tmp/php8SdQOI [error] => 0 [size] => 436817 ) )
This is with a file that works. When I throw a file of size 835213 at it both arrays are empty.
OS is linux, apache server. Upload works fine wiht anything under 450KB so i dont see it as a coding issue as much as a server config issue. I just need to track down the culprit causing this.
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Here are some things that might help (from the manual)
Also, have you tried different browsers?
If you're on a shared host that won't allow you to modify the php.ini file and your max_upload_size is set low, you can create an .htaccess file in the upload handler script directory that contains:
php_value upload_max_filesize 8000000
Uploading huge files still remains a problem, even after you've set upload_max_size and post_max_size to reasonable sizes (in my case respectively the defaults 2M and 8M).
MAX_FILE_SIZE is often ignored and php doesn't cut in to stop the transfer, so if you're using Apache (i'll bet you are) try limiting transfers with LimitRequestBody.
Be advised that you don't set this directive too low, or Apache will return a document without data.
^^^ thats probably gonna help you the most.If you we dumb like me you installed Redhat 8.0 and kept the default install of packages for Apache 2.0 and PHP4.2.2. I could not upload any files larger than 512kB and all the php directorives were set to 32MB or higher.
memory_limit = 128M
post_max_size = 64M
upload_max_filesize = 32M
And my upload web page was set to 32MB as well:
<Form ID="frmAttach" Name="frmAttach" enctype="multipart/form-data" action="attachments.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="33554432" />
However, the insiduous php.conf (/etc/httpd/conf.d/php.conf) file used by default RPM install of Redhat httpd has a LimitRequestBody set to 512kB ("524288" ). Adjusting this to 32MB ("33554432") got things going for the larger files. Here is my php.conf file in its entirety. Hope this helps someone. L8er.
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php4_module modules/libphp4.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 33554432
</Files>
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
Also, have you tried different browsers?
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
yes i have tried different browsers. It is definately the php.conf 512KB LimitRequestBody that is causing the problem. The question is if i dont have access to the file can it be changed at runtime?
Thanks for confirming my situation i was beginning to think i was the only one that had encountered such a problem. Very frustrating
Thanks for confirming my situation i was beginning to think i was the only one that had encountered such a problem. Very frustrating
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
you could try putting
into an .htaccess file, or maybe even just
Code: Select all
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 33554432
</Files>Code: Select all
LimitRequestBody 33554432-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
It works if I put it in an .htaccess file, that's odd.
I set it to '5' and i get:
LimitRequestBody 0, should make it unlimited though.
I set it to '5' and i get:
Maybe it gets overridden by the php.conf, i don't know, im not a big linux guy.Request Entity Too Large
The requested resource
-----------------
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
--------------------------------------------------------------------------------
Apache/1.3.27 Server at -------- Port 80
LimitRequestBody 0, should make it unlimited though.
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
-
liquidkool
- Forum Newbie
- Posts: 9
- Joined: Thu Feb 20, 2003 7:50 am