Fixed an image upload problem - might help others!

cmilkosk

Joined: 2003-07-06
Posts: 1
Posted: Sun, 2003-07-06 14:27

All - I don't know if others had a problem with uploading images > 512K in size, but I did some research in my web server logs and found:

[Sun Jul 06 09:56:47 2003] [error] [client 192.168.0.1] Requested content-length  of 1132291 is larger than the configured limit of 524288, referer: http://cmilkosk.pointclark.net/modules.php?get_albumName=album03&op=modload&name=gallery&fil
e=index&include=add_photos.php

So, I did a quick lookup in the Google newsgroups for this, and found a reply to someone with the same problem:

Quote:
From: stchupack (frellu@hotmail.com)
Subject: Re: File Upload error

View this article only
Newsgroups: comp.infosystems.www.servers.unix
Date: 2002-10-20 12:59:07 PST

I was having the same problem with RedHat 8, Apache 2x, and PHP 4x.
Take a look in /etc/httpd/conf.d/php.conf

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288
</Files>

This file is added to httpd.conf as an include, so it's very easy to
miss any configuration settings that might be set here.

BTW, you can set LimitRequestBody to zero, which is the same as
setting no limit. Although I'd recommend setting it the same as your
max php upload size.

Hope this helps.

I just raised my LimitRequestBody, and all worked fine! Yay! :D

I hope this helps others.

Chris

 
alindeman
alindeman's picture

Joined: 2002-10-06
Posts: 8194
Posted: Sun, 2003-07-06 14:55

I meant to add something similar to the FAQ. I'll do that in a bit. Thanks :)

 
ymehui

Joined: 2003-02-25
Posts: 5
Posted: Mon, 2003-07-07 00:58

Hi,

I tried this but still have upload problem.....

setup: RH9, Apache 2.0.40, PHP 4.2.2, Gallerey 1.3.4

The first 2 pictures usually added and resize ok, then some thumbnail and resize pic got corrupted and getting all the errors....

Anyone encountered this?

Edmond

================
debug info from debug mode:

- Adding 03_canoe_camp_20.jpg

Executing:

/usr/bin/jpegtopnm /var/www/html/albums/canoe03/03_canoe_camp_20.jpg | /usr/bin/pnmscale -xysize 150 150 | /usr/bin/pnmtojpeg --quality=95 > /var/www/html/albums/canoe03/03_canoe_camp_20.thumb.jpg

Results:

none

Error messages:

jpegtopnm: WRITING PPM FILE

Status: 0 (expected 0)

Executing:

/usr/bin/jhead /tmp/gallery/photo.03_canoe_camp_20.jpg

Results:

File name : /tmp/gallery/photo.03_canoe_camp_20.jpg
File size : 1544331 bytes
File date : 2003:07:06 20:52:01
Camera make : Canon
Camera model : Canon PowerShot S230
Date/Time : 2003:05:17 16:33:41
Resolution : 2048 x 1536
Flash used : Yes
Focal length : 10.8mm (35mm equivalent: 74mm)
CCD width : 5.26mm
Exposure time: 0.0080 s (1/125)
Aperture : f/10.0
Metering Mode: matrix
Jpeg process : Baseline

Error messages:

Status: 0 (expected 0)IN UTIL ITEMCAPTUREDATE = 2003

- Resizing 03_canoe_camp_20.jpg

Executing:

/usr/bin/jpegtopnm /var/www/html/albums/canoe03/03_canoe_camp_20.jpg | /usr/bin/pnmscale -xysize 500 500 | /usr/bin/pnmtojpeg --quality=95 > /var/www/html/albums/canoe03/03_canoe_camp_20.sized.jpg

Results:

none

Error messages:

jpegtopnm: WRITING PPM FILE
jpegtopnm: Error writing single byte sample to file
pnmtojpeg: EOF / read error reading magic number

Status: 1 (expected 0)

Executing:

/usr/bin/jhead /var/www/html/albums/canoe03/03_canoe_camp_20.jpg

Results:

File name : /var/www/html/albums/canoe03/03_canoe_camp_20.jpg
File size : 1544331 bytes
File date : 2003:07:06 20:52:55
Camera make : Canon
Camera model : Canon PowerShot S230
Date/Time : 2003:05:17 16:33:41
Resolution : 2048 x 1536
Flash used : Yes
Focal length : 10.8mm (35mm equivalent: 74mm)
CCD width : 5.26mm
Exposure time: 0.0080 s (1/125)
Aperture : f/10.0
Metering Mode: matrix
Jpeg process : Baseline

Error messages:

Status: 0 (expected 0)
- Adding 03_canoe_camp_21.jpg

Executing:

/usr/bin/jpegtopnm /var/www/html/albums/canoe03/03_canoe_camp_21.jpg | /usr/bin/pnmscale -xysize 150 150 | /usr/bin/pnmtojpeg --quality=95 > /var/www/html/albums/canoe03/03_canoe_camp_21.thumb.jpg

Results:

none

Error messages:

jpegtopnm: WRITING PPM FILE
pnmtojpeg: EOF / read error reading a one-byte sample
jpegtopnm: Error writing single byte sample to file

Status: 1 (expected 0)
Error: Unable to make thumbnail (0)!

 
ymehui

Joined: 2003-02-25
Posts: 5
Posted: Mon, 2003-07-07 02:08

I also realized that the same problem occur to resizing picture. It puzzle me that it looks like some kind of unflush cache problem to me... If I wait for a while and resize again, the piture turn out ok. And when it failed, I saw this error:

pnmtojpeg: EOF / read error reading a one-byte sample
jpegtopnm: Error writing single byte sample to file

 
TypeSDragoon
TypeSDragoon's picture

Joined: 2003-04-03
Posts: 42
Posted: Tue, 2003-07-08 08:40

i looked at the php.conf file, but it only said this:

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

it doesn't have the LimitRequestBody line

i'm also having problems uploading anything > 2MB~

this is the error message i get:
Processing status...
- Adding CRW_4484.jpg
Warning: Unable to open '' for reading: No such file or directory in /var/www/html/gallery/platform/fs_unix.php on line 24

Warning: getimagesize: Unable to open '/var/www/html/albums/TypeSDragoon/acb.jpg' for reading. in /var/www/html/gallery/util.php on line 473

Error: Invalid image: acb.jpg!

 
TypeSDragoon
TypeSDragoon's picture

Joined: 2003-04-03
Posts: 42
Posted: Tue, 2003-07-08 08:55

i found the answer to my problem here http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=7375

it worked :)

now i can finally upload images > 2MB :)

/etc/php.ini

 
alindeman
alindeman's picture

Joined: 2002-10-06
Posts: 8194
Posted: Thu, 2003-07-10 14:22

Added to the new FAQ...

 
ymehui

Joined: 2003-02-25
Posts: 5
Posted: Mon, 2003-07-14 02:43

I already had the upload_max_filesize > 2M, but my problem didn't go away...

Error message still say:
pnmtojpeg: EOF / read error reading a one-byte sample
jpegtopnm: Error writing single byte sample to file

Retry after a while works.... it's just weird.

ED$

 
skizzybiz

Joined: 2004-05-27
Posts: 3
Posted: Thu, 2004-05-27 18:04

I'm having all the same problems as previous people in this thread, but none of the suggestions seem to help. I keep getting errors along the lines of "Request content-length of 508155 is larger than the configured limit of 75000" in my apache error log, and on the client side it's a "Requested Entity Too Large" error. I'm running Gallery 1.4.3pl1, PHP 4.2.3, and Apache 1.3.23. My server's php.ini has post_max_size = 8M and upload_max_filesize = 2M (which I'm not able to change, since I'm not an admin), and the Gallery .htaccess has set both of those values to 20971520. I tried setting the LimitRequestBody in .htaccess to 0, and then to some very large number. Nothing seems to affect this problem. I've managed to upload one very small photo, about 300x300 pixels, which is below the 75k limit. Anything else gets rejected.

Ideas?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Thu, 2004-05-27 18:34

You will have to contact your host to change the LimitRequestBody. It's probably a setting that you're not allowed to override, since that's the wall that you're hitting.

 
skizzybiz

Joined: 2004-05-27
Posts: 3
Posted: Thu, 2004-05-27 18:47

That's what I thought, but I have read access to all the apache config files (except the ssl key file), and the only mentions of LimitRequestBody set it to 2147483647, and that is for a vhost file that doesn't affect my site. Anyway I have "AllowOverride all" on my site, so I should be able to change everything in a .htaccess file.

Thanks for the quick reply!

 
molotov

Joined: 2004-06-14
Posts: 1
Posted: Mon, 2004-06-14 16:35

Squid users: also make sure that your proxy allows making requests, which are big enough to carry your photos. You can accomplish that by entering the following line in squid.conf, i.e.:

request_body_max_size 4 MB

Restart squid after this and things should work.

 
skinsch

Joined: 2004-11-28
Posts: 3
Posted: Wed, 2004-12-01 05:30

The Squid change fixed my problem! I was using Apache 1.3.13 and the 2.x references weren't helping. Thanks.

 
alagran

Joined: 2005-01-09
Posts: 1
Posted: Sun, 2005-01-09 08:34

I've had these files size problems as well. I've follow the suggestions on this form which I needed to do, but needed just one more thing to help me to upload a 50MB video file.
edit the .htaccess under the gallery directory and change the following

php_value post_max_size 80000000
php_value upload_max_filesize 80000000
php_value magic_quotes_gpc off

This helped me to the final result that I needed.

 
shawn

Joined: 2002-11-03
Posts: 22
Posted: Sat, 2005-02-05 05:33

For a single site / single server, the original post did the trick for me.

However, I can also see where a complex virtual host enviroment would warrant these changes.

Regardless, I was stumped until finding this.

Thanks So Much!

 
jessebedard

Joined: 2005-04-25
Posts: 1
Posted: Mon, 2005-04-25 15:34

thats all it takes

 
cdl

Joined: 2005-05-15
Posts: 2
Posted: Sun, 2005-05-15 09:49

"All - I don't know if others had a problem with uploading images > 512K in size, but I did some research in my web server logs and found: "

yeah and error logs are very helpfull :D

http://www.2pc.pl/

 
Mike250
Mike250's picture

Joined: 2007-03-30
Posts: 4
Posted: Fri, 2007-03-30 17:15

I am using GoDaddy.com for hosting and found the following information which worked for me.

Locate php.ini in the root folder and add the following:

memory_limit = 50M
post_max_size = 8M
file_uploads = On
upload_max_filesize = 8M