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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rshgeneral
Forum Newbie
Posts: 4
Joined: Fri Feb 05, 2010 8:41 pm

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

Post 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?
Last edited by rshgeneral on Sat Feb 06, 2010 1:26 am, edited 2 times in total.
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

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

Post 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.
rshgeneral
Forum Newbie
Posts: 4
Joined: Fri Feb 05, 2010 8:41 pm

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

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

Make sure display_errors is enabled too - otherwise you won't see any messages regardless of the error_reporting level.
rshgeneral
Forum Newbie
Posts: 4
Joined: Fri Feb 05, 2010 8:41 pm

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

Post 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.
rshgeneral
Forum Newbie
Posts: 4
Joined: Fri Feb 05, 2010 8:41 pm

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

Post 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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post by Eran »

error reporting and display errors are two different settings. Make sure to follow tsairis suggestion and enable display errors
Post Reply