How to send file over internet using http headers

R

Raichu

Hi All,

I'm new to VC++.net and I searched through the forums and couldn't
find anything related to this.

I'm trying to send a flat file from a VC++.net program to a PHP file
residing on a webserver. I know you can call a website from
VC++.net, but I'm not sure how to send a physical file over the
internet. I mean is there a way to mimic a normal html form to
upload a file, using VC++.net?

Any information or links would be appreciated.

Thanks.
 
C

Carl Daniel [VC++ MVP]

Raichu said:
Hi All,

I'm new to VC++.net and I searched through the forums and couldn't
find anything related to this.

I'm trying to send a flat file from a VC++.net program to a PHP file
residing on a webserver. I know you can call a website from
VC++.net, but I'm not sure how to send a physical file over the
internet. I mean is there a way to mimic a normal html form to
upload a file, using VC++.net?

Any information or links would be appreciated.

You can make an HTTP POST using any number of technologies including:

0. Winsock
1. WinInet (wrapper over Winsock)
2. WinHttp
3. MFC (wrapper over WinInet)


To send a file you need to simulate a form-url-encoded posting with an
appropriate MIME type. Basically, you need to build of a string that
contains the necessary headers and content to simulate a form post, and then
send it using one of the technologies above.

You can learn all the details of the form encoding by looking at the
apprproaite RFCs at www.ietf.org. Some RFC numbers that would be of
interest include:

2045, 2046, 2047, 2048, 2049, 2854

another technique is to use a network monitor ("packet sniffer") to capture
the data sent by a standard web browser (such as IE) when executing the
actual form post. You then simply substitute your file data into the post
at the appropriate place (and set the content length correctly, of course).

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top