-1

I've troubles uploading a file bigger then 500MB on Apache/PHP server on my local machine. I've tried with php.ini configuration, .htaccess, ecc. But i can't solve the problem.

On my phpInfo the variables are currently set like this:

upload_max_filesize 2048M
post_max_size   2048M
memory_limit    1024M

What should i change? I'm running xampp 3.2.2 on win7 (same problem on win10).

Apache Version Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30

Thanks!

------ update: here's more detailed errors:

Warning: POST Content-Length of 941609661 bytes exceeds the limit of 524288000 bytes in Unknown on line 0
Notice: Undefined index: page_selector in C:\xampp\htdocs\upload_file.php on line 6
Notice: Undefined index: nome_video in C:\xampp\htdocs\upload_file.php on line 7
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 8
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 31
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 33
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 34
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 35
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 36
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 37
Notice: Undefined index: file in C:\xampp\htdocs\upload_file.php on line 38

where the reported lines are:

$page = $_POST["page_selector"];
$nome_video = $_POST["nome_video"];
$label = $_FILES["file"]["name"];
$extension   = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/wma")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg"))
max88_it
  • 17
  • 7
  • so a 499 MB size works but >500 MB doesn't? Did you test to see if smaller files get uploaded? – Kahn Kah Apr 18 '17 at 08:17
  • You should provide a detailed error message. Also have you checked this: http://stackoverflow.com/a/18414806/25429 – zloster Apr 18 '17 at 08:22
  • Thanks @zloster, i've tried with other solutions, as .htaccess, but the error is always the same 'Warning: POST Content-Length of 633016961 bytes exceeds the limit of 524288000 bytes in Unknown on line 0'. The php.ini is set, the .htaccess is also set correctly, the phpInfo returns the value i've set, but i'm still getting the error. – max88_it Apr 18 '17 at 09:00
  • 1
    @zloster thanks! After some different approches i finally tried https://github.com/blueimp/jQuery-File-Upload as you suggested in your linked solution. It works. Thanks – max88_it Apr 18 '17 at 13:03

2 Answers2

0

Set the variables upload_max_filesize, post_max_size, memory_limit in php.ini to the right values and restart the server, then it should work.

It is possible that you edited the wrong php.ini file! Check with phpinfo() to see if you actually edited the correct .inifile.

Kahn Kah
  • 1,389
  • 7
  • 24
  • 49
  • Hi, i've check the phpInfo, and the .ini file is the correct one. On my phpInfo page (xampp) the variables are correct. But still i can't upload big files. I'll try to print the error and paste it here. Thanks – max88_it Apr 18 '17 at 08:39
  • did you restart your server? – Kahn Kah Apr 18 '17 at 08:39
  • Warning: POST Content-Length of 633016961 bytes exceeds the limit of 524288000 bytes in Unknown on line 0 – max88_it Apr 18 '17 at 08:46
  • This is the error i'm getting.... somewhere there's a limit... yes, ive stopped and restarted the server. Should I restart the pc? – max88_it Apr 18 '17 at 08:47
  • it means somewhere in your files there is the value `524288000` that needs to be changed – Kahn Kah Apr 18 '17 at 08:58
  • restart everything if you're sure that you did everything correct. Else recheck the files and `ctrl+f` with the value ` 524288000´ – Kahn Kah Apr 18 '17 at 08:59
  • Restart everything, apache, xamp,win7 – Kahn Kah Apr 18 '17 at 09:01
  • Restarted everything. Same error. 524288000 is exactly 500MB.. i'll search for that value in all the config files.... – max88_it Apr 18 '17 at 09:06
  • You have done the phpinfo() on the page where the error is generated to check the correct location of the `ini` file right? – Kahn Kah Apr 18 '17 at 09:13
  • http://stackoverflow.com/questions/21704930/how-to-prevent-warning-post-content-length-and-memory-size check this – Kahn Kah Apr 18 '17 at 09:15
  • Sadly is not working... "php_flag display_startup_errors off" suppress the error/warning log, but the file is still not uploading. – max88_it Apr 18 '17 at 09:27
  • http://php.net/manual/en/configuration.changes.modes.php check this and edit it here. it must be something wrongly configured – Kahn Kah Apr 18 '17 at 09:31
  • Solution found. Chunked-file upload is the way! Thank you anyway. – max88_it Apr 18 '17 at 13:09
-1

Solution!

php.ini configuration was correct. The file was too big to be handled by a single POST. So i tried a plugin that handles a chunked-file upload.

With this apporach (and this plugin) the problem is fully solved!

https://github.com/blueimp/jQuery-File-Upload

Thanks to everyone for your support.

max88_it
  • 17
  • 7
  • what 'upload configuration' are you talking about? – Kahn Kah Apr 20 '17 at 11:48
  • [edited] Sorry, by "upload configuration" i mean how i was uploading the file. A single POST with a >500MB file triggers the error. With a splitted/chunked file Upload i've no more problems. – max88_it Apr 20 '17 at 13:30