user2884505 user2884505 - 1 year ago 80
PHP Question

PHP - $_FILES empty after large file upload on Azure

I've setup an Angular based file upload using the ng-file-upload plugin ( and I've been handling the file upload with a PHP script.

The file upload and script work on smaller files (tested it on < 1MB), but fails on a larger file (9MB). This leads me to believe that there's a file upload issue. However, I've already created a .user.ini file in the /wwwroot folder with a single line:


Is there another reason why the $_FILES and $_POST arrays would be empty?

JS Code:

url: '/scripts/receiveFile.php',
file: file
}).then(function(resp) {
}, function(resp) {
}, function(evt) {
var progressPercent = parseInt(100.0 * evt.loaded /;
console.log(progressPercent + "%");

HTML Code:

<input type="file" accept=".zip" ngf-select="submitFile($file)"></input>

PHP Code:

$file_name = basename($_FILES['file']['name']);
$file_tmp_name = $_FILES['file']['tmp_name'];

The script fails because 'file' is undefined in the $_FILES array - because the $_FILES array is empty.


Answer Source

PHP has a confusing was of doing file uploads. To set a larger upload size, you should set both upload_max_filesize and post_max_size. These can be independently different values, as they do different things.

post_max_size is the maximum file size that can be sent in a POST request to the PHP script. upload_max_filesize is the maximum file size allowed via any method.