0

I have the following code on python which basically sends an HTTP request containing a file on a remote server

url = 'http://localhost:8080/opt/in/QueryPartner'    
files = {'my_file': ('@' + 'client.xml', open(os.path.join(settings.MEDIA_ROOT, 'client.xml'), 'rb'), {'Expires': '0'})}
r = requests.post(url, files=files)
alert (r.text)

which corresponds to a similar CURL-command

curl -F''my_file=@client.xml'' http://localhost:8080/opt/in/QueryPartner

THE QUESTION

I need to perform a similar request using JS only (no python) so that the request is sent from the client machine. I understand that this should be a simple Ajax call, but I wonder what would be the correct syntax to pass on a file in the http request. Any hint would be highly appreciated

Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121

0 Answers0