Page 1 of 1

File Upload size

Posted: Thu Mar 03, 2005 4:49 pm
by khawarikhan
Hi Eveybody,
I had posted this message before and someone did reply to the post but that solution didn't work. Actually, I am trying to upload files bigger than 500K on my server. But its not allowing it to upload those files. I checked that I am not passing any variable MAX_FILE_SIZE as a hidden field in the form and have checked the php.ini file and it says that the Max size to upload is 2MB which I set to 5MB now but still it not working. Anyone has any idea how to remedy this problem? Thanks for help

Khawar Khan

Posted: Thu Mar 03, 2005 4:54 pm
by feyd
check the error element of the $_FILES element you are checking against. It may lead you to your answer.

Posted: Thu Mar 03, 2005 4:57 pm
by Chris Corbyn
$_FILES['userfile']['error']
EDIT: Dammit... I was beaten :lol:

thanks for replying

Posted: Thu Mar 03, 2005 5:16 pm
by khawarikhan
I tried to print this Variable after I hit the upload button, what I see only is........."The page cannot be displayed" error.........it doesn't show anything until the upload file size is less than 500K :(

Khawar

Re: thanks for replying

Posted: Thu Mar 03, 2005 5:29 pm
by Chris Corbyn
khawarikhan wrote:I tried to print this Variable after I hit the upload button, what I see only is........."The page cannot be displayed" error.........it doesn't show anything until the upload file size is less than 500K :(

Khawar
Show some code please (and the bit where you echo/print the error element from $_FILES)

here is the code

Posted: Thu Mar 03, 2005 5:37 pm
by khawarikhan

Code: Select all

if ($save)
{
   if ($Image=="") {
       $upload_message="You have not uploaded any file <br>\n";
   } else {
   if (is_uploaded_file($Image)) {
       $location="LOCATION GOES HERE" . $Image_name;
       copy("$Image", $location);
       $file_error1 = $_FILESї'$Image_name']ї'error'];
       echo "eror1: $file_error1<br>";
       if (file_exists($location)) {
          $upload_message="$Image_name uploaded successfully!<br>";
       } else {
          $upload_message="There was a problem uploading your file to $location. Please check the path and permissions.";
       }
       Header("Location: import.php?filename=$Image_name");
   } else {
       $upload_message="Wrong type of file, please try again!";
   }
   }
}

feyd | please use

Code: Select all

tags while the

Code: Select all

tags are offline![/color]

Posted: Thu Mar 03, 2005 5:37 pm
by feyd
very likely, you are viewing in IE and you didn't send back 256 bytes of data.. IE will display a 404 page if less than 256 bytes are sent back.

Posted: Thu Mar 03, 2005 5:43 pm
by smpdawg
As mentioned in other posts you need to look at post_max_size and file_max_size. If they are each set to some value that is larger than the files you are expecting and the transfer still fails you have another problem.

And here is what your problem may be. There is a flag called LimitRequestBody in Apache that will give the illusion of a configuration error in PHP. This only affects certain installs of Apache and I have seen it happen in Red Hat Linux.

This flag is set to a value in the neighborhood of 500K depending on the installation so if you transfer fails with files that are bigger than ~500K and work with smaller files this may be your problem.

http://www.apacheref.com/ref/http_core/ ... tBody.html

BTW - Even though this page talks about Apache 1.3 I have seen it happen to Apache 2.0.

RE: smpdawg

Posted: Thu Mar 03, 2005 5:53 pm
by khawarikhan
So how can I increase the size for that then?

Khawar

Posted: Thu Mar 03, 2005 5:55 pm
by feyd
output more characters.. they can be almost anything.. spaces.. carriage returns.. garbage..whatever.. as long as the stream hits 256 or more bytes..

RE: fyed

Posted: Thu Mar 03, 2005 6:04 pm
by khawarikhan
Sorry for pasting the code without the

Code: Select all

block........I'll do it next times for sure.........
I tried outputting garbage data, a lot of it actually, but still the same error with IE...........page cannot be displayed.........

Khawar

Re: RE: smpdawg

Posted: Thu Mar 03, 2005 6:08 pm
by smpdawg
khawarikhan wrote:So how can I increase the size for that then?

Khawar
post_max_size is in your php.ini. LimitRequestBody would be in httpd.conf or could be loaded from an external file that httpd.conf is pointing at.

Verify post_max_size and upload_max_filesize in your php.ini before you check the Apache configuration file.


If php.ini looks normal, read this page to get an idea where LimitRequestBody can be. I cannot say for a fact where you will find it because each distro is different.

https://www.redhat.com/archives/taroon- ... 00340.html