[SOLVED] Multipart files upload. File length?
Posted: Wed Feb 03, 2021 1:51 pm
i upload two files and dont know how to get thier context length and data
should i search in POST every time data boundary ? ----WebKitFormBoundarywjRojsBoPY7GpAWu
is there some 'BOUNDARY-content-length' like a HTTP head content-length ?
there are many heavy weight python libraries that handles file uploading, but they are too big to fit in memory.
q5.txt (data QQQQQ)
w5.txt (data WWWW)
(or some jpeg binary file)
HTML code for loading multiple files
After pressing upload button i read socket and get data:
HTTP head
'content-length': 431
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundarywjRojsBoPY7GpAWu'
POST data
should i search in POST every time data boundary ? ----WebKitFormBoundarywjRojsBoPY7GpAWu
is there some 'BOUNDARY-content-length' like a HTTP head content-length ?
there are many heavy weight python libraries that handles file uploading, but they are too big to fit in memory.
q5.txt (data QQQQQ)
w5.txt (data WWWW)
(or some jpeg binary file)
HTML code for loading multiple files
Code: Select all
<html>
<body>
<form enctype = "multipart/form-data" action = "/upload" method = "post">
<p>File: <input type = "file" name = "filename" multipart /></p>
<p><input type = "submit" value = "Upload" /></p>
</form>
</body>
</html>
HTTP head
'content-length': 431
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundarywjRojsBoPY7GpAWu'
POST data
Code: Select all
b'------WebKitFormBoundarywjRojsBoPY7GpAWu\r\n
Content-Disposition: form-data; name="filename"; filename="w5.txt"\r\n
Content-Type: text/plain\r\n
\r\n
WWWWW\r\n
------WebKitFormBoundarywjRojsBoPY7GpAWu\r\n
Content-Disposition: form-data; name="filename"; filename="q5.txt"\r\n
Content-Type: text/plain\r\n
\r\n
QQQQQ\r\n
------WebKitFormBoundarywjRojsBoPY7GpAWu\r\n
Content-Disposition: form-data; name="_Path"\r\n
\r\n
Test\r\n
------WebKitFormBoundarywjRojsBoPY7GpAWu--\r\n'