Unable to upload large files - php

I have a laravel project that uses AJAX to send files to be uploaded to the server. All works just fine for as long as the file is less than 100MB. But large files like 450MB and up are not being saved on the server despite receiving a response that the file has been saved.
I am using Apache and my php.ini files have both max_upload_size = 1024MB and max_post_size = 1024MB.
Please help, any info that will be of helping in debugging I can provide.
Thanks.

I know its been long, since I posted this question and I found the answer a long time. But just in case someone is also having the same issue.
It turns out I had a .htaccess file in the public folder that was overiding the server configurations for this specific virtualhost.

Related

How can increase the file upload size in Moodle when I upload the Course file?

I am uploading a zip file there but it says Error connecting to the server and I have changed the php.ini memory_limit = 9024m
There are a few places that might cause this upload issue.
I would suggest looking at your PHP.ini file to make sure that the setting there is correct.
Check the apache side as well.
With regards to increasing moodle upload sizes here is the doc: Moodle Doc
Edit 1: Error connecting to server is the default Moodle error it prints when your upload file is either too big or takes too long to upload, thus your connection times out.

PHP - File uploading process resets

I'm trying to upload files over 150MB with a PHP file, which works without any problem with files less than 40Mb. But when I try to upload files like 150 to 200 MB, it resets the upload process after uploading about half of the file.
It repeats again and again when the new upload process gets to same value, till the time limits on php.ini file kills the process.
The first thing I tried was increasing those values in my php.ini file:
post_max_size=450M
memory_limit=300M
max_execution_time=1600
max_input_time=1600
upload_max_filesize=400M
and file_uploads is of course set to On.
I also put this line to top of my upload.php file:
set_time_limit(0);
I'm running that website on Windows Server 2008 R2 with Parallels Plesk 12.0.8.
I search this problem on Google too much but none of the solutions work on my case.
I read the same scenario in this question, which the owner of the question replied that he solved the problem by increasing client_max_body_size value in nginx.conf file, but I could not find anything about this file in Windows server so I thought it is only exists on Linux systems.
What could cause this problem?
I've solved it.
I changed PHP's debugger from FastCGI Application to CGI Application on Plesk, and that solved it.
But be careful, it caused me a couple of errors in other pages of the website, and I've fixed them all again.
Hope that helps.

Can't upload large file in Laravel (php.ini settings are correct in my opinion)

I have the following problem in Laravel.
I would like to upload a file through a form. But for some reason if the file is larger than around 2100 KB, the validation fails, and says that the file is 'required' and I did not provide it.
I've read numerous articles, that this can be because of php.ini settings. On my server they are the following:
upload_max_filesize 64M
post_max_size 64M
These values are copied from the output of phpinfo(), so they are in effect.
And despite this, the upload fails even for a 2 MB file. Do you have any ideas what I could check/set to solve this?
I am using laravel 5.2, and PHP 7.
Check which server software you are using. Nginx for instance has it's own limit (default set to 1MB I believe). Apache might have it too. Consult the respective manuals for those packages on how to configure them. Or if you're using shared hosting, contact support to see if they can increase the limit.
Though this isn't a really scalable solution. Next time you might want to upload a 100MB file, and you probably don't want to allow 100MB requests on your servers. A better approach would be to split the file in smaller chunks in the frontend, with JavaScript, and submit them as parts of the same upload, then recombine the parts on the server once the file is completely uploaded. Beware of additional checks you'll have to do here though.
You might want to incorporate the following into your own code:
<?php
//--- this tries to override the default of only 2M file uploads.
ini_set("upload_max_filesize","25M");
ini_set("max_execution_time",600); //--- 10 minutes
ini_set("post_max_size","35M");
ini_set("file_uploads","On");
?>
In my case, it was HDD space issue. not enough space to store the file.
Laravel should handle it with proper message, instead of indicating user didn't upload anything.
If you are not using any other package to upload files to check , then
then remember to restart apache .

Can't upload file

I've made an CMS for a customer. One of the things he can do is upload a PDF file. We've tested this thoroughly and haven't encountered any bugs. However, he can't seem to upload anything at all. The file is never uploaded. His browser just keeps loading.
My client uses Firefox (not sure which version but I thought that wouldn't matter) and the PDF files he attempts to upload are around 5MB, nothing extreme.
Is there any reason why a browser doesn't finish it's request when uploading a file? I don't think the files are corrupt.
I don't think the problem lies in my script... but still worth posting:
if(!empty($_FILES['pdf'])) {
$path = '../pdf/';
$filename = $_FILES['pdf']['name'];
if(!empty($assoc['pdf'])) {
$oldfile = $path.$assoc['pdf'];
if(file_exists($oldfile)) {
unset($oldfile);
}
}
$success = move_uploaded_file($_FILES['pdf']['tmp_name'], $path.$filename);
}
Edit: He has sent me the PDF he's trying to upload. Took about 10 seconds to upload... I'm providing him a link to do a speed test, lol.
You can have two problems i see, might not be your exact problems but could lead you to your answer.
#1. POST_MAX_SIZE or UPLOAD_MAX_FILESIZE is not big enough
There are two configs that php programmers often forget about and this is probably your most obvious problem. Your tests have been done but have they been done with large files?
Using an htaccess or a php.ini (depending on your server configuration) you can override the php settings for
upload_max_filesize
post_max_size
And give them 20M for example:
/*.HTACCESS*/
php_value upload_max_filesize 20M
php_value post_max_size 20M
/*PHP.INI*/
upload_max_filesize = 20M
post_max_size = 20M
You cannot use ini_set() because these variables are used BEFORE php starts processing and thus would become useless in the context.
#2. enctype is not multipart/form-data
Although very unprobable, you might have forgot to set your enctype property on your form to "multipart/form-data" and thus, nothing gets sent to the server at all. But i doubt this is your issue since you said you tested it extensively.
BUT, sometimes, we move things around and forget to test (it happens to me too) and i was sure something worked before and now it's not, so check it out just to make sure :)
Good luck
Have the client try uploading the file in a different browser than Firefox. If it works in others browsers, try deleting (or renaming/moving, for testing purposes) the file MimeTypes.rdf in the client's Firefox profile folder.
If the PDF upload works afterwards, you encountered a Firefox bug that was first reported in 2007 (basically the same here, reported in 2006). In a nutshell, any web site from which the user ever downloads a file has the potential to corrupt the MimeTypes.rdf file in regards to the extension of the downloaded file - maliciously or accidentally/unknowingly.
Things you can do:
Vote for the Firefox bug!
Quick fix to get it working for the client right now: Have the user(s) delete their MimeTypes.rdf file. Firefox will create a new, "fresh" one at the next start, but this will clear all MIME type / application associations that the user has created over time. Also, this will only help until the user downloads the next PDF file from some other web site that corrupts the MimeTypes.rdf file again.
Use the "user agent" header to determine if the file is uploaded from Firefox. If so and the MIME type doesn't match anything you wish to accept, double-check the file name's extension and accept the file anyway if the extension matches your accepted file type(s) (".pdf" in your case).

Is there any way to Upload Video Files using PHP?

I want to upload and store video files to my server using PHP. Could any one please provide me some example about how to upload a large file using PHP?
Please keep in mind that these files are generally larger than 200 MB.
I think the question is fairly limited, is it the post size where there are problems? Uploading files of this size, really should be handled by something else than the normal upload control. You should see if you can give the user a progress on the upload, because otherwise users probably will cancel the upload if it takes too long.
First hit on google: Google search
http://bluga.net/projects/uploadProgressMeter/
Look at this move_uploaded_file, but if it's so big, it needs to be allowed in php.ini to upload this big files. And maybe you will have problem with Apache as well, because default time when it disconnects you is 5 minutes.
You will need to edit PHP.INI and change those two parameters:
upload_max_filesize = 500M
post_max_size = 500M
...for a maximum upload filesize of 500MB.
If you have a properly set-up server you can put php.ini files into your htdocs root, and it will be effective.

Categories