1

I have an ajax query to send a form "have an upload file input" to a php file,

to send the file a formData like that :

var formData = new FormData();
var file = $("#logo").get(0).files[0];
formData.append("logo", file);

and I have other input values that I wanna send with it which is name , password,email ... and here is the object I created for that :

{name:name, email:email, password:password, auth:auth}

so I'm asking how to send the formData + this object as data in ajax here :

$.ajax({
    data :  ...... ?
});
ADiL
  • 367
  • 4
  • 17

1 Answers1

-1

You have to append each element within the serialized form data into the formData object.

Refer here: Send FormData and String Data Together Through JQuery AJAX?

Community
  • 1
  • 1
Kyle Emmanuel
  • 2,193
  • 1
  • 15
  • 22
  • thanks for the answer , I tried it but the serialized data dosen't sent , and this is for the multiple file ! I have only 1 file to upload not multiple , how can I do this ? thanks. – ADiL Aug 18 '14 at 00:22
  • Regardless whether multiple or single files, the logic is there. you must iterate through each value within the `serialize()` data and append it to the `formData` object. – Kyle Emmanuel Aug 18 '14 at 03:24