Php file upload – (large file size) – (blank page, no error) – PHP



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 needed 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. This problem was posted here but it doesn’t appear as if any solution was reached.

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:

<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 />

Relevant script code:

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?



Is display_errors enabled in your PHP.ini?
I ask because if it is not, no errors will be displayed regardless of how you set error_reporting.

The only Apache settings I know of that would cause it to reject files are the "LimitRequestBody" directive and possibly "RLimitMem". You may want to search your .conf and .htaccess files for those.


Display errors is set to On. I had read about the LimitRequestBody online, but I don’t know how to check what it is currently set to. My host is GoDaddy, its a Linux shared hosting account. Can those two directives be set in the php.ini file? If so what values should I used. I don’t need to post files via HTTP much any bigger than 150-200MB.


You can’t set Apache directives through PHP. At least not these. The PHP code wouldn’t be executed until after the uploaded file had been rejected by Apache.

Seeing as you are on a shared environment, I would check with the host. See if they are putting limits on the amount you can upload. – I would guess that most hosts would limit it to a few MiB, for performance reasons.

Event though I doubt they would give you control over these sort of limits, you could try creating a .htaccess file and set them anyways.


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.


OK, I see. That I would not have guessed.
I have heard of uploads failing using the default temp directory (on Windows mostly), but that has always completely disabled it, not partially.

But anyways, I’m glad you got it fixed 🙂


go to php.ini

and find this configration

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

then change size to other like 128 or 256

from khartoum – sudan


Hey mozmel.

This issue has already been resolved a while back, as rshgeneral posted in his last entry. And the config directive you suggested was also a part of the directives mentioned in the original post, which had no effect on the problem.