php.ini max_upload_filesize and post_max_size are being ignored it seems, AJAX response coming back with file too large error

328 views Asked by At

I've set both of these to 20M in my php.ini and have restarted php-fpm as well as rebooted the server but still files are being rejected as being too large. Or at least, I'm getting the "Request Entity Too Large" response in my AJAX call.

Below is my AJAX call:

var fd = new FormData();
fd.append("field", "upload_variant_picture");
fd.append("product_id", productId);
var files = $("#image-upload\\:"+escapedDiv)[0].files[0];
var fileSize = files.size/1024/1024;
if(fileSize > 20){
    alert('File size is too large (max 20MB).');
    return;
}
fd.append('new_image',files);
if(files){
    $.ajax({
    url: "https://"+host+"/.../update-product.php",
    mimeType: "multipart/form-data",
    type: 'post',
    data: fd,
    contentType: false,
    processData: false,
    success: function(response, textStatus, xhr){
        //...
    },
    error: function(xhr, textStatus, errorThrown){
        if(errorThrown == 'Request Entity Too Large'){
            alert('File uploaded is too large.');
        }
    }
    });
}

No matter what, I can't get the file to upload with this call. Any advice is appreciated.

0

There are 0 answers