upload file to server not working in python -
i'd upload files server using python. means in case when write http://example.com/files/ in browser i'd see de.txt there in list of files. how should change script working? when run it, python shell writes out nothing, >>>.
thanks in advance!
import requests url = 'http://example.com/files/' user, password = 'ex', 'ample' files = {'upload_file': open(r'c:\users\example\desktop\code\de.txt','rb')} r = requests.post(url, auth=(user, password), files=files)
writing file across network
import requests requests.auth import httpbasicauth url = 'http://example.com/files/' user, password = 'ex', 'ample' files = {'file': ('de.txt', open('de.txt', 'rb'), 'multipart/form-data', {'expires': '0'})} r = requests.post(url, auth=httpbasicauth(user, password), files=files)
for reference use python request documentation
Comments
Post a Comment