I want to upload the file with Ajax in DRF, but I fail!
var form = new FormData();
form.append("files[1]file", "/home/mshzsh/Pictures/photo.jpg");
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://127.0.0.1:8000/api/pc/update/155/",
  "method": "PUT",
  "headers": {
    "User-Agent": "PostmanRuntime/7.20.1",
    "Accept": "*/*",
    "Cache-Control": "no-cache",
    "Postman-Token": "379c280a-c620-4e5f-8b9b-0ace0a9e6fa6,8c381931-20bb-480d-827d-11bb05718224",
    "Host": "127.0.0.1:8000",
    "Content-Type": "multipart/form-data; boundary=--------------------------641148104724362550775599",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "1355503",
    "Connection": "keep-alive",
    "cache-control": "no-cache"
  },
  "processData": false,
  "contentType": false,
  "mimeType": "multipart/form-data",
  "data": form
}
$.ajax(settings).done(function (response) {
  console.log(response);
});
I have copied these codes from the postman but I get error :
The submitted data was not a file. Check the encoding type on the form.
I tried a variety of AJAX methods but failed!
Note: These codes work correctly in Postman and Curl
 
    