14

I would like to upload a file using JQuery-File-Upload, but using HTTP "PUT" instead of multipart-forms. According to their site:

- Multipart and file contents stream uploads:
    Files can be uploaded as standard "multipart/form-data" or file contents stream (HTTP PUT file upload).

but I cannot find anywhere in their documentation as to how to do this. Can anyone help?

Sled
  • 18,541
  • 27
  • 119
  • 168

2 Answers2

7

According to : https://github.com/blueimp/jQuery-File-Upload/wiki/Options

method

The method of the HTTP request used to send the file(s) to the server. Can be POST (multipart/formdata file upload) or PUT (streaming file upload). Accepts a String or a function returning a String.

You should use :

$('#file_upload').fileUpload({
    namespace: 'file_upload_1',
    url: '/path/to/upload/handler.json',
    method: 'PUT'
});
mathieu
  • 30,974
  • 4
  • 64
  • 90
  • Sorry, but I looked at that page and still do not see from where you got. :'( Sorry, but it could be because I barely know JavaScript. In fact http://api.jquery.com/jQuery.ajax has the field "type" mentioning PUT and GET. – Sled Apr 01 '11 at 20:47
  • updated answer. you set options when you intitilize your fileupload component – mathieu Apr 01 '11 at 20:59
  • I definitely saw that before and just didn't understnad what it was saying. Thank you for your clarification. – Sled Apr 01 '11 at 21:07
0

I love REST too but you might want to make sure you unit test well on the browsers you need to support.

http://api.jquery.com/jQuery.ajax/

The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they may not supported by older browsers.

See this answer How do I PUT data to Rails using JQuery

Community
  • 1
  • 1
SavoryBytes
  • 35,571
  • 4
  • 52
  • 61