0

How Can I create below multi-part form data request by uploading file in Python?

------WebKitFormBoundaryKVAJlF8rFOTxL7jq
Content-Disposition: form-data; name="file"; filename="txtresume.txt"
Content-Type: text/plain
------WebKitFormBoundaryKVAJlF8rFOTxL7jq-- 

also how can i post this request in python

Muthu
  • 27
  • 1
  • 6
  • Your answer is here : https://stackoverflow.com/questions/12385179/how-to-send-a-multipart-form-data-with-requests-in-python – Mehdi Jan 22 '20 at 11:14

1 Answers1

0

You can use requests module to post file

import reqeusts
url = 'http://yoururl/'
files = {'file': open('xxx.xls', 'rb')} # or files = {'file': ('xxx.xls', open('xxx.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}
r = reqeusts.post(url, files=files)

For more resource you can view this link

Amit
  • 244
  • 1
  • 2
  • 11