Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload a file using an HTTP "PUT" using JQuery?

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?

like image 598
Sled Avatar asked Apr 01 '11 20:04

Sled


People also ask

Can we upload file using AJAX?

File upload is not possible through AJAX. You can upload file, without refreshing page by using IFrame .


1 Answers

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'
});
like image 125
mathieu Avatar answered Oct 20 '22 14:10

mathieu