-1

I have a jquery function:

$.ajax({
    type: "POST",
    url: "submit.php",
    contentType:'multipart/form-data',
    data: $('#regForm').serialize(),
    dataType: "json",

its work perfectly but image and files will not be send by this. how can I resolve it?

Ziaullah
  • 65
  • 2
  • 6
  • 1
    possible duplicate of [jQuery Ajax File Upload](http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload). The answer is that you can't upload files like this. – Lix Sep 26 '12 at 14:05
  • Take a look at [uploadify](http://www.uploadify.com/). It might suite your needs for ajax uploading of files. – Lix Sep 26 '12 at 14:06

1 Answers1

1

You cannot upload files directly with Ajax, but you can use an hidden iframe, and send form data using the target="iframe_name" attribute in <form>, see this tutorial: http://www.coursesweb.net/ajax/upload-images

CoursesWeb
  • 4,179
  • 3
  • 21
  • 27
  • There's also the extended ability to handle files [available in newer browsers.](http://caniuse.com/#feat=xhr2) – Pointy Sep 26 '12 at 14:33