Im confused... I can't seem to upload files in the 2gb range. When i try using curl to send a 1.92gb file to my site (through an API), it doesn't report anything at all, its just blank. When i send a 1kb file, it reports back like it should.
When i try uploading via the upload form, it ends up freezing mid way, around 33%. Although im not sure if only the progress bar has froze or if the actual file upload it self has been suspended. I suspect that only the progress bar has froze because it still says data is being sent even though the progress bar freezes.
My php.ini (yes, its reflected by phpinfo as well):
register_globals = Off
magic_quotes_gpc = Off
post_max_size = 2047M
upload_max_filesize = 2047M
max_execution_time = 25200 ; Maximum execution time of each script, in seconds
max_input_time = 25200 ; Maximum amount of time each script may spend parsing request data
memory_limit = 2048M ; Maximum amount of memory a script may consume (16MB)
short_open_tag = On
My vps doesnt actually have 2gb of ram at its disposal, but does memory_limit really need to be set this high?
How should i go about testing this? I know 400mb files work, i haven't tested anything in between 400mb and 1.92gb
You will need a premium account to test up to 2gb, so here is one you can play with:
User: testreferral
Pass: 1234
http://filefx.com
I dont understand where this problem is arising.
Check for:
Memory limit. Try uploading files above and below the actual memory limit.
Time limit. Aren't your uploads take 7+ hours, are they?
The effective settings. Some setting might be overridden by server/etc settings.
PHP: mysql query skipped/ignored after large file uploads?
Mysql was timing out during the file upload. So the file wasn't showing up in the DB
Related
I know this question has been asked before, but I've gone through all previously described options and I'm wondering if I'm missing an option. I'm trying upload a file through Apache/PHP that is greater than 2.000GB in size. Files smaller than that work fine.
The following php.ini variables are set, and I have restarted Apache to make sure they are in effect:
max_input_vars = 10000
post_max_size = 5000M
upload_max_filesize = 5000M
max_file_uploads = 1000
max_execution_time = 600
max_input_time = 600
memory_limit = 10000M
I am using a javascript uploader, with no filesize limits in the script, and a PHP page to receive the uploaded files, also with no limits in the script. When it fails, it only gives this error message in the javascript console in Chrome and IE: Failed to load resource: net::ERR_CONNECTION_RESET. There are file size limit checks in the javascript and PHP pages, but those errors are never displayed... so I'm thinking it is not even getting the chance to check the file size in either place.
In case anyone hits this 2.0GB limit, the fix for me was that PHP 5.4 did not support uploads greater than 2.0GB. This limit was changed in PHP 5.6: http://php.net/ChangeLog-5.php#5.6.0
Upgrading to PHP 7.0 worked for me!
I'm fairly new to PHP, but I'm having a recurring issue via multiple different scripts and servers when uploading images via ShareX to my server with a custom script, specifically this one.
I've migrated servers (I was on a shared host, now I'm on a VPS), and have since changed to using this script, but I'm still having the issue and I don't know what exactly the problem is.
The issue (does not occur 100% of the time, but it does most of the time; sometimes it works after retrying) is that uploading images over a certain size, about 250-500KB times out or fails most of the time. After 60 seconds, I get a 502 error (Bad Gateway) on ShareX.
I've looked up common solutions to similar problems ("large" files timing out in PHP), and have checked the following variables in my PHP.ini file.
max_execution_time = 60
max_input_time = 60
memory_limit = 128M
post_max_size = 8M
When uploads are successful, it takes a few seconds in total to upload and get the link of the uploaded image returned, but when it fails, it's always 60 seconds and then error. There is no middle ground, it's either it succeeds instantly or times out after 60 seconds.
I don't know exactly how to go about finding what exactly the error (if any) is. When it happens, ShareX reports a (502) Bad Gateway error, the 'Response:' is just the source code of the page (the script is set up to redirect you to this page if it detects you aren't uploading anything or it fails), and the 'Stack Trace' is the following:
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at ShareX.UploadersLib.Uploader.UploadData(Stream dataStream, String url, String fileName, String fileFormName, Dictionary`2 arguments, NameValueCollection headers, CookieCollection cookies, ResponseType responseType, HttpMethod method, String requestContentType, String metadata)
Edit: My server is behind cloudflare, and I read that cloudflare might cause problems. However, I've checked the settings and the maximum upload size is set at 100MB on cloudflare, and pausing it doesn't seem to help.
Edit: I removed the limit on post_max_size which was 8M and it seems to have partly fixed the issue. I can now upload things up to about 3MB but after that it always fails with a custom error message from the script.
When increasing file POST limits, you may need to change at least 2 settings:
upload_max_filesize = 30M
post_max_size = 32M
Dont think it has anything to do with CloudFlare. See if you can check the error log for Apache if the above settings dont work.
I am building a website with an upload form. It will upload only up to 120 Kb but the browser times out if anything bigger is tried. No error message, the browser just times out.
What I've done so far:
Changed all php.ini settings, .htaccess settings;
Tried different browsers;
Rebuilt the form on another server (hosting company) and it works fine
(removed everything from the upload except the bare basics);
This is where it starts getting weird. It works fine on my friends computer.
I think I've eliminated:
The coding - because it does work;
The server - because it works fine on their computers and on my friends computer
The browser - Well I've used another web-hosting company and the form works fine with them, so I'm guessing it's not a browser problem, or even my internet connection problem or maybe even settings on my computer?
The problem is on my website the form won't work for anything over 120 kb. On the test website on another server it does work. It's only my computer it doesn't work on other peoples computers it does work. Why and why set at 120 kb. Am I missing something?? I'm taking this very personally, it's as if the internet, my computer, or technology just doesn't like me.
EDIT 1:
I've just tried something else. I got another computer and tried it on that to eliminate the possibility it was a problem with the computer. Still doesn't work on a different computer at my house - so I'm thinking my broadband provider? But that doesn't explain why the test website on another server works okay??
Review your settings in:
php.ini
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size=10M
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize=512M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 10
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; http://php.net/max-input-time
max_input_time = 60
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
It's important after editing php.ini file to restart your httpd server, to re-read php.ini file!
Make sure that you set units correctly. There is no shorthand-bytes
like "MB". You should use "K", "M", "G" for that.
Check this PHP FAQ.
httpd.conf or/and .htaccess
php_value post_max_size 10M
php_value upload_max_filesize 512M
If it really is only your computer, it probably is a browser problem. Have you tried different browsers on your computer? Have you tried disabling all browser plugins and extensions?
If you changed all of your PHP settings in php.ini & you are sure that they are set—perhaps via phpinfo() reflecting your settings—and it still doesn’t work it sounds like it might be a firewall issue where the network itself is limiting content being uploaded.
Unclear what this server is or where you have it setup, but I bet a firewall setting is in play.
I'm writing an app that accepts .mp4 uploads.
So I've a 24.3MB .mp4 that is posted to the server, but it fails silently.
The next smallest file I have is a 5.2MB .flv. It's not the file type of course, but file size.
I wonder if anybody could shed some light on this?
P.S. the relevant php.ini entries are as follows:
memory_limit = 256M
upload_max_filesize = 32M
Help!
You should also set post_max_size. Files are sent using HTTP POST.
I wonder if it's encoding-related. Base64 encoding = 33% greater size. 24.3 * 1.33 = 32.4 MB > 32 MB. Try a 23.9 MB file and see if that succeeds
Set error reporting level to E_ALL. Might give you some hint about what's going wrong.
post_max_size is a good idea, also you should check for timeouts. Since uploading larger files takes longer, the webserver might decide it's all taking too long and cancel the request. Check for maximum execution time in php.ini, also check whether there are other server-side time limits (I know of webervers where all tasks are killed after 30 secs. no matter what. An upload might easily take longer than that).
Have you considered using a Flash-Based uploader? This gives you more control over the upload process, and you can display a progress bar during upload (more user-friendly)
I have a php web page with 15 fields. The user will use it to upload images. I tested this by uploading 15 jpg images, each about 2 M, without any problems. On the day I launch, I will be moving this web page to another Linux shared hosting environment (still not sure which). Are there some web hosting environments that limit the size of total uploads in one http request?
Yes. There are (as far as I can remember) three or so configuration settings which will affect upload size restrictions:
upload_max_filesize, which sets an upper limit on the size of uploaded files
post_max_size, which limits the total size of posted data, including file data
max_input_time, which restricts the length of time the script is allowed to process input data, including posted values
upload_max_filesize is a limit on each individual file; however, post_max_size is an upper limit on the entire request, which includes all the uploaded files.
Different hosting environments will have these values set differently, which may affect your abilities upon deployment.
The upload limits are set through php ini. You can try get them like so:
$post_max_size = ini_get('post_max_size');
$upload_max_filesize = ini_get('upload_max_filesize');
It's a setting in php.ini. You can look in the output of php info for the field labeled "upload_max_filesize". To get a php info page, create a php file with the following code:
<?php phpinfo(); ?>
This post at php.net gives you sample code to get that information, and the rest of the page is a treasure trove of php configuration options.
There are bunch of PHP settings limiting the upload process:
file_uploads
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size
I'd suggest reading this page: http://www.radinks.com/upload/config.php
While it's true many of these don't limit upload size, they do put a cap on the upload process - e.g. if memory limit is too low, then you'll have problems uploading big files that need to stay in memory for a little period of time.
This would be unusual, but of course, check with whatever hosting company you choose. If there were a limit, it certainly would be higher than 30 MB.
the php.ini directive "post_max_size" should limit how much data you can send in a single POST. if you post 15 images in one post I'm pretty sure that is still considered one POST. So it might be good to check this value before going live.
If you are using nginx then make sure that you have the following:
server {
...
client_max_body_size 100M;
....
}
here:
max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize
max_file_uploads
I've seen the best solution here so far, and this is the code:
/**
* Returns the maximally uploadable file size in megabytes
*
* #return string
*/
function getMaxUploadSize()
{
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$memory_limit = (int)(ini_get('memory_limit'));
return min($max_upload, $max_post, $memory_limit);
}