javascript - File not received at server using FormData


I'm uploading a form containing a file to my server, which runs validation and returns success or failure.

The form is sent using Ajax and FormData.

On my test server all data, including the file is received. However, on my live server it returns saying that this file is missing.

If i interrogate the FormData object in both environments the file is present, it just never seems to make it to the server.

Obviously i've removed a couple of items and replaced with *s and also the post url is generated by the page.



    $('form').submit( function( e ) {
    formData = new FormData( this );
        xhr: function() {
            var xhr = new window.XMLHttpRequest();

            xhr.upload.addEventListener("progress", function(evt) {
                if (evt.lengthComputable) {
                   var percentComplete = evt.loaded /;
                   percentComplete = parseInt(percentComplete * 100);
                   percentShown = percentComplete*0.98;
            }, false);

            return xhr;
        url: '{{Request::url()}}/process',
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false
    }).done(function(data) {
        if (data[0] == 0) {
            console.log( data[1][0] );
            console.log( data[2] );
        else if (data[0] == 1) { 



If your code is working on test server then just check folder permission and folder location. permission should be 777.


People are also looking for solutions to the problem: Facebook dilema; how to remove all members and add them back again, via PHP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.