I'm having a heck of a time getting this to work. The form code...
<div bran="uplo">
<form name="uplo" method="post" enctype="multipart/form-data" action="upload.aspx">
<input type="hidden" name="proc" value="wagr"/>
<span>Data File:</span>
<span>
<input type="file" name="wagr"/>
</span>
</form>
<span>
<button onclick="document.uplo.submit();">Upload</button>
</span>
</div>
Here's the 356th version of the code I've tried...
url = 'https://www.example.com/upload.aspx'
files = {'file':('data.txt', open('data.txt', 'rb'))}
data = {'proc':'wagr'}
r = requests.post(url, files=files, data=data)
All that seems to happen when I look at r.content
is the page itself and that is all.
I asked for permission here is the actual form...
First, check your post.
------WebKitFormBoundaryJQcvwSzBape4lDoO
Content-Disposition: form-data; name="proc"
wagr
------WebKitFormBoundaryJQcvwSzBape4lDoO
Content-Disposition: form-data; name="wagr"; filename="test.py"
Content-Type: text/x-python
------WebKitFormBoundaryJQcvwSzBape4lDoO--
This is mine, you can see, name
for file should be wagr
.
Second, check your response.
Actually, it will return a page but contains more information based on the file you uploaded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.