473,411 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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

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:
Expand|Select|Wrap|Line Numbers
  1.  <form enctype="multipart/form-data" method="POST" action="uploader.php">
  2.         Choose a file to upload: <input name="userfile" type="file" /><br />
  3.         <input type="submit" value="Upload File" /><br />
  4. </form>
Relevant script code:
Expand|Select|Wrap|Line Numbers
  1. error_reporting(-1);
  2. if (move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/FreeAudio.mp3'))
  3.     echo "File is valid, and was successfully uploaded.\n";
  4. else echo "Error when uploading file\n";
What am I missing?
Feb 6 '10 #1
7 7107
Atli
5,058 Expert 4TB
Hey.

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.
Feb 6 '10 #2
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.
Feb 7 '10 #3
Atli
5,058 Expert 4TB
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.
Feb 7 '10 #4
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.
Feb 9 '10 #5
Atli
5,058 Expert 4TB
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 :)
Feb 9 '10 #6
mozmel
1
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

thanks
mozmel
from khartoum - sudan
May 17 '10 #7
Atli
5,058 Expert 4TB
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.
May 17 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: smilesinblues | last post by:
Hi, I have to allow my visitors to upload image on my site. I am using the follwoing code to do that: $uploaddir = 'admin/'; $uploadfile = $uploaddir . basename($_FILES);...
1
by: lazyadmin | last post by:
I would like to use this code on my website to allow simple file uploads from clients. I would like to restrict the file types they can upload. Can this be done? Any help appreciated. Rod...
6
by: Robert Strickland | last post by:
What is the default file size limit when uploading a file and can the administrator up that limited when needed?
1
by: Nawaz Ijaz | last post by:
Hi All, Just need to know that how can it be possible to upload large file in chunks of bytes. Suppose i have a large file (100 MB) and i want to upload it in chunks (say 20 KB). How can this be...
1
by: Kevin Yu | last post by:
hi All is there any good solution to uploading/passing file as parameter to a web service call? thx Kevin
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
0
by: sandya | last post by:
here is the code i tried string ss; //FileUpload FileUpload1 = new FileUpload(); Label Labeltxt = new Label(); //FileUpload1 = FormView1.FindControl("FileUpLoad1") as FileUpload; FileUpload...
1
by: JJ | last post by:
Is it possible to have a file upload control (either the built in one or to write one) that only allows the user to browse for certina extensions? (i.e. only shows *.gif files for example, when the...
0
by: Bhavan Thejpal | last post by:
hi, in a web application we are building, we have a 'upload file' functionality.I need to check whether the user is uploading a valid word file.( it should be a valid, uncorrputed Word file). ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.