0

So i'm sending a jquery object that contains some info about a file and the actual $("#input").files[0]; item.

The jquery/javascript looks something like the following:

$.ajax({
    url: '/upload/create',
    type: 'POST',
    dataType: 'json',
    data: JSON.stringify(data),
    success: function(msg) {
        alert(msg);
    }
});

The data variable is a JQuery object that contains info about the uploaded file and the file itself(I think), I just passed it in the object.

Is there any way to extract and save this file on the server-side with PHP?

1 Answer 1

1

Just remove the JSON.stringify() call and you should be good. data should be an object, which gets converted to PHP's associative $_POST or $_GET array, stringify converts it to a string.

data: data,
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.