0

We have a modal form with an input of type file. We want to upload the file to the server when the user clicks 'Save'. We don't want to actually refresh the page, but simply close the modal.

Can we upload a file via $.ajax? Otherwise, what tools are available for uploading files behind the scenes?

Travis Parks
  • 8,435
  • 12
  • 52
  • 85

1 Answers1

1

$.ajax() will work, but you'll do best to specify a POST. See the answer here:

Sending multipart/formdata with jQuery.ajax

Also, this jquery plugin supports file uploads:

http://jquery.malsup.com/form/

Community
  • 1
  • 1
Jonathan M
  • 17,145
  • 9
  • 58
  • 91