Python uploads files through multipart protocol post

< form id= "w0" class= "form-horizontal" action= "/ report/add?_=1535094880131" method= "post" enctype= "multipart/form-data" >
< input type= "hidden" name= "_ csrf" value= "4nOPKuOaFi3F2pKZwCPje9xQM4aIwKOZiHWUSoSGnDqls7uo4HY5aAClc0nVhRust OIMloA "reportform-url" class= "report_pdf_new" name= "ReportForm [url]" >
< p class= "help-block help-block-error" >


< / div >

this is the source code of the web page. I use the following method to write, why did the upload fail

files= ["ReportForm [url]", ("Qijia net COO Mao Xinyong: "Future platform empowerment is inevitable, but it only makes sense if it is a real knife and gun"-18 pages. Pdf", str (open (file,"rb"). Read ()), "application/pdf")]

Data={"_csrf":csrf_token}

headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
        }

response=requests.post(url=url,cookies=cookies,data=Data,headers=headers)
print(response.request.body)-sharp-sharp-sharp 



Apr.28,2021

I really don't understand your question, what exactly are you asking?
doesn't understand the intent of your code either.

recommend a url:
python-requests.org/zh_CN/latest/user/quickstart.html-sharppost-multipart-encoded" rel=" nofollow noreferrer "> http://docs.python-requests.o.

Menu