1

Hi I need to send a file to my backend from browser with PUT. I have a input type file where I select the file and then try to send it via jquery ajax.

Basically What I need to do is to simulate this request witch is passed as an example in my REST interface documentation.

PUT http://localhost:8099/upload
Content-Type: application/binary
Filename: C:\ProgramData\ualdscert.der

This is my javascript so far... but still not working. Any help will be much appreciated.

 $("#fileUpload").change(function(){
    $.ajax({
            url: "/upload",
            type: "PUT",
            data: { Filename : $("#fileUpload").val()},
            processData : false,
            error: function(jqXHR, textStatus, errorThrown) {
                alert("Error: " + errorThrown);
            },
            success: function(responseData){
               alert(""succes");
            }
        }); 
});
user3573766
  • 241
  • 1
  • 2
  • 6
  • You aren't actually uploading a file - you are just `PUT`-ing the filename. You need to read the file data and send it along as part of your request. – Adam Jenkins Apr 20 '16 at 14:12
  • http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously – Gogol Apr 20 '16 at 14:12

0 Answers0