I am trying to upload a file using the javascript formData object.
var formData = new FormData(form[0]);
formData.append('attachments[]',
localStorage.getItem('file_content'));
$.ajax({
url: form[0].action,
type: "POST",
enctype: 'multipart/form-data',
processData: false,
contentType: false,
cache: false,
data: formData,
success: function(response){
console.log(response);
}
});
So the local storage 'file_content' has the file content in blob format. The above code works, but the problem is that the file content is submitted as $_POST variable. I want the file to be submitted and available in the $_FILES server variable. Is it possible to do that. Please help.