upload & download using HTTP
I am new to HTTP, I am wanting to download & upload files from/to a webserver, I have taken a look at CHttpFile, can anyone provide any sample code demonstrating both upload & downloading using CHttpFile class, or the approach I will have to take to achieve this.
Regards
Filbert....
# 1 Re: upload & download using HTTP
From
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/vcrefchttpfilesendrequestex.asp
pFile->WriteString(strData);
pFile->EndRequest();
CString strData = Some very long data to be POSTed here!;
pServer = sess.GetHttpConnection("mooseboy");
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/isapi.dll?");
pFile->SendRequestEx(strData.GetLength());
pFile->WriteString(strData);
pFile->EndRequest();
# 2 Re: upload & download using HTTP
Thanks for the reply,
Will this code work on all web servers, as I have been told use HTTP is for reading and I need to use FTP for uploading...
# 3 Re: upload & download using HTTP
That's not true. HTTP has various commands.
GET: For fetching data (HTML pages, images, files, etc)
POST: For uploading data (forms, files, etc).
There are absolutely no problems uploading files using HTTP.
If you are not familiar with the entire protocol, you could read its RFC at ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt
There are various freeware third party implementations available for HTTP. I'm currently using one called cURL (http://curl.haxx.se) . Its got a C based API and is extremely good. You could give it a try.