Page 1 of 1

PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Fri Feb 05, 2010 10:51 pm
by rshgeneral
I am having difficulty uploading some large files using php/html form. The code has worked for file sizes up to 23MB. When I've tried a 50MB file, i get a blank page instead of my confirmation echo statement. My web research indicates that I need to alter some php directives either in an .htaccess file or php.ini. I have edited my php.ini file and included all the relevant directives I could find. Here are the newly added lines. I have confirmed the changes with a phpinfo() request.
memory_limit = 210M
post_max_size = 200M
upload_max_filesize = 190M
max_input_time = 2400
max_execution_time = 2400
I don't even think max_execution_time is even relevant here, but it has been mentioned on several web pages.

Relevant form code:

Code: Select all

<form enctype="multipart/form-data" method="POST" action="uploader.php">
        Choose a file to upload: <input name="userfile" type="file" /><br />
        <input type="submit" value="Upload File" /><br />
</form>
Relevant script code:

Code: Select all

error_reporting(-1);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/FreeAudio.mp3'))
    echo "File is valid, and was successfully uploaded.\n";
else echo "Error when uploading file\n";
What am I missing?

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Sat Feb 06, 2010 12:27 am
by Bind
http://www.php.net/manual/en/features.f ... tfalls.php
http://www.php.net/manual/en/ini.core.p ... t-max-size
POST_MAX_SIZE - Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size . When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Sat Feb 06, 2010 12:43 am
by rshgeneral
I've already viewed this information at the links described before I posted. Notice that my memory limit is > post_max_size which is > upload_max_file_size.

I have not inclued the MAX_FILE_SIZE hidden form element because it doesn't appear to be required. My files have uploaded without this element. Is it required?

I'm not sure what is to be gained by utilizing
This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.
Are $_GET variables available before $_POST variables?

Honestly, with no error messages, I have no idea how to solve this problem.

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Sat Feb 06, 2010 12:34 pm
by requinix
Make sure display_errors is enabled too - otherwise you won't see any messages regardless of the error_reporting level.

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Sat Feb 06, 2010 12:43 pm
by rshgeneral
Isn't that what error_reporting(-1); does? I've since changed it to error_reporting(E_ALL); but it hasn't made a difference.

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Tue Feb 09, 2010 12:39 am
by rshgeneral
Changing the tmp_upload_dir from the default, which was a the shared /tmp off of root, to a directory underneath my user directory fixed the issue. I'm not sure why this works, but it does.

Re: PHP FILE UPLOAD - (LARGE FILE SIZE) - (BLANK PAGE, NO ERROR)

Posted: Tue Feb 09, 2010 3:36 am
by Eran
error reporting and display errors are two different settings. Make sure to follow tsairis suggestion and enable display errors