S
S
strager12020-09-07 09:11:56
Lighttpd
strager1, 2020-09-07 09:11:56

How to upload a file to the server via POST request?

The task is to transfer the file from the computer (windows) to the controller (ubuntu) through the web face. That is, the user must select a file through the html form and this file is loaded into a specific directory of the controller. The problem is that in the POST request received from the page, there is no link to the file. The server is lighttpd, the c++ programming language.

HTML page:
<h2>Загрузка ПО</h2>
<form enctype="multipart/form-data" action="cgi?downloadpost" method="post">
<fieldset><label> Укажите путь к загружаемому файлу <input name="g1" type="file"></label></fieldset><p>&nbsp;</p><p align=right><input type="submit" name="button" value="Загрузить" />
</p></form>

There is nothing in cgi?downloadpost yet, but this should not interfere with sending a normal POST request, as a result, it looks like this:
POST request
Request URL: 192.168.0.200/cgi-bin/cgi?downloadpost
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: 192.168.0.200:80
Referrer Policy: strict-origin-when-cross-origin
Content-Length: 369
Content-Type: text/html
Date: Mon, 07 Sep 2020 11:03:48 GMT
Server: lighttpd/1.4.45
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 294
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryMOqMNc77OxgqUi3l
Host: 192.168.0.200
Origin: 192.168.0.200
Referer: 192.168.0.200/cgi-bin/cgi?download
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36

As far as I understand, the name of the uploaded file file.txt should appear somewhere here, but it is nowhere to be found.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hanneman, 2020-09-07
@strager1

This is how the decrypted POST request looks like (the test.txt file is sent in the form with the test content text inside).
5f55e383690b7109711376.jpeg
You have in the examples the response from the server. not a request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question