|
-
April 27th, 2006, 02:30 PM
#1
https upload file
Hi everyone,
I should start out by saying, I do not know ANY C++, I have to modifiy someone else's code, to upload a file over https to a php script on the webserver.
This works now by using FTP. I have the code that does this below
Code:
int UploadFile(const char *serverName, const char* localFile, const char* remoteFile)
{
int error = 0;
CFtpConnection *ftp = NULL;
BOOL ok;
try {
CInternetSession session(_T("Upload/1.0"));
ftp = session.GetFtpConnection(serverName, "user", "pass");
ok = ftp->SetCurrentDirectory(_T("data"));
if (ok) {
ok = ftp->PutFile(localFile, remoteFile, FTP_TRANSFER_TYPE_ASCII);
}
if (!ok) {
error = GetLastError();
}
}
catch (CInternetException* exc) {
error = GetLastError();
}
// if the connection is open, close it
if (ftp != NULL) {
ftp->Close();
}
delete ftp;
return error;
}
So my question, is can someone write in a drop in replacement code for this. You can hardcode the URL in the code. I am using vb.net C++.
As I really don't know what I am doing, I am willing to pay for someone to do this, let me know and we can work out a price.
Thank you,
Mike
Last edited by mlh; April 27th, 2006 at 02:37 PM.
-
April 27th, 2006, 02:57 PM
#2
-
April 27th, 2006, 03:57 PM
#3
Re: https upload file
I was hoping that there would be a small amount of code someone could point me to and use. I do know perl and php. If there is a well documented class that does this, I could figure it out. I will also post the request in the places you have offered.
Thank you,
Mike
-
April 27th, 2006, 04:30 PM
#4
Re: https upload file
You may find WinInetPost helpful.
Gort...Klaatu, Barada Nikto!
-
May 12th, 2009, 08:12 AM
#5
Re: https upload file
 Originally Posted by mlh
Hi everyone,
I should start out by saying, I do not know ANY C++, I have to modifiy someone else's code, to upload a file over https to a php script on the webserver.
This works now by using FTP. I have the code that does this below
Code:
int UploadFile(const char *serverName, const char* localFile, const char* remoteFile)
{
int error = 0;
CFtpConnection *ftp = NULL;
BOOL ok;
try {
CInternetSession session(_T("Upload/1.0"));
ftp = session.GetFtpConnection(serverName, "user", "pass");
ok = ftp->SetCurrentDirectory(_T("data"));
if (ok) {
ok = ftp->PutFile(localFile, remoteFile, FTP_TRANSFER_TYPE_ASCII);
}
if (!ok) {
error = GetLastError();
}
}
catch (CInternetException* exc) {
error = GetLastError();
}
// if the connection is open, close it
if (ftp != NULL) {
ftp->Close();
}
delete ftp;
return error;
}
So my question, is can someone write in a drop in replacement code for this. You can hardcode the URL in the code. I am using vb.net C++.
As I really don't know what I am doing, I am willing to pay for someone to do this, let me know and we can work out a price.
Thank you,
Mike
sorry i'm new to C++ but what do i include to make this code work?
-
May 12th, 2009, 10:58 AM
#6
Re: https upload file
Uploading a file via https is considerably more complex than uploading over FTP.
Remember that HTTP was primarily developped as a RECEIVE-only type query. Posting data takes a bit of work.
You will need to read the file, convert the binary data to 7bit ascii so it can be posted. This will require you to create a routine to use one of the binary-to-ascii converscion schemes supported by your web server. The most common one being 'application/octet-stream'.
The FTP code is a few lines. Expect a https upload solution to be several dozen lines to maybe a couple hundred lines of code... Mainly to turn the file you want to upload into the proper HTTP post-compatible format.
-
May 13th, 2009, 06:43 AM
#7
Re: https upload file
On linux C++ this is easily done with openssl.
The windows openssl could do it too but the current version moronically pauses a second between each step.
e.g.
openssl s_client -host adwords.google.com -port 443
POST /api/adwords/v13/AdGroupService HTTP/1.0
Host: adwords.google.com
SOAPAction: ""
Content-Length: 952
YOUR CONTENT OF 952 bytes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|