Answer the question
In order to leave comments, you need to log in
How to accept in Django a file sent through a third-party script on Angular + jQuery?
A project on Django is spinning on the host, next to it I attached a file manager working on Angular + jQuery.
When uploading a file to the server, a file (or several files) arrives in the view, how can I process them correctly and accept them?
Here is a piece of tcpdump from the server while trying to upload a file to the /var/tmp folder:
POST /fm/ HTTP/1.1
Host: host:8000
Connection: keep-alive
Content-Length: 70374
Accept: application/json, text/plain, */*
Origin: http://host:8000
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryj6Btc1bFDjedIGOc
Referer: http://host:8000/static/fm/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en,ru;q=0.8,en-US;q=0.6
Cookie: viewTemplate=main-table.html; language=en; __utma=65702700.1399815119.1414040013.1420897593.1420897593.12; SESSbb33813eba54a737490d2e105cbe8ab9=226v8r5is8vq4f287ko6ehsen2; djdttop=29; djdt=hide; sessionid=0wlfe8oqqq3g9encti7uwahtgmk6jb5f; csrftoken=GsBYMpeMa8F6wnrhYOTNM0N3Vy7Yqt7x
WebKitFormBoundaryj6Btc1bFDjedIGOc
Content-Disposition: form-data; name="destination"
/var/tmp
------WebKitFormBoundaryj6Btc1bFDjedIGOc
Content-Disposition: form-data; name="file-0"; filename="flood.png"
Content-Type: image/png
.PNG
...
Answer the question
In order to leave comments, you need to log in
All files received via this data are available in self.request.FILES['doc'], where doc is the submission form
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question