Skip to content Skip to sidebar Skip to footer

Uploading File To Server Using C++ Http Request

So I am attempting to upload files to a server from a windows 7 client using winsock. In order to do this I have setup the socket and then created an HTTP POST request that is supp

Solution 1:

The issue that I was having was actually relatively simple to fix. First I needed to add a user-agent, second I needed to define a content-length which was the length of the ENTIRE http request (not just the data portion). My finished HTTP Request then appears as:

POST /upload.php HTTP/1.1
Host: localhost
Content-Length: 800
Content-Type: multipart/form-data; boundary=WrbKitFormBoundaryXtRo8bh7ZpnTrTwd
User-Agent: 1337
Connection: keep-alive

--WrbKitFormBoundaryXtRo8bh7ZpnTrTwd
Content-Disposition: form-data; name="fileToUpload"; filename="testMac.cpp"
Content-Type: application/octet-stream

//SEND RAW FILE DATA HERE

--WrbKitFormBoundaryXtRo8bh7ZpnTrTwd

Post a Comment for "Uploading File To Server Using C++ Http Request"