FtpPutFile problem
-
Hi all. I've tried to use this but it doesnt seem to work. One time i tried it and it worked very well. The second time i tried it it didnt work. What it does is it connects well and sends the file. But problem is that there is nothing in the text file. Here is what i have so far.
#include #include #include using namespace std; void FileSubmit() { char *user="user"; char *pass="password"; char *ftpserver="ftp.server.com"; HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession, "C:\\test.txt", "file.txt", FTP_TRANSFER_TYPE_ASCII, 0) == TRUE){ cout << "File Sent! " << endl; Sleep(1000); InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); } else{ cout << "File didnt send " << endl; } } int main(){ FileSubmit(); return 0; }
I know text files need to be sent in ASCII mode so i switched to that and it still didnt work. It uploads the file but the file is empty. Whats going on??? Thanx in advance! -
Hi all. I've tried to use this but it doesnt seem to work. One time i tried it and it worked very well. The second time i tried it it didnt work. What it does is it connects well and sends the file. But problem is that there is nothing in the text file. Here is what i have so far.
#include #include #include using namespace std; void FileSubmit() { char *user="user"; char *pass="password"; char *ftpserver="ftp.server.com"; HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession, "C:\\test.txt", "file.txt", FTP_TRANSFER_TYPE_ASCII, 0) == TRUE){ cout << "File Sent! " << endl; Sleep(1000); InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); } else{ cout << "File didnt send " << endl; } } int main(){ FileSubmit(); return 0; }
I know text files need to be sent in ASCII mode so i switched to that and it still didnt work. It uploads the file but the file is empty. Whats going on??? Thanx in advance!Try opening the connection in passive mode..... I had the same problem.... worked for me.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
-
Hi all. I've tried to use this but it doesnt seem to work. One time i tried it and it worked very well. The second time i tried it it didnt work. What it does is it connects well and sends the file. But problem is that there is nothing in the text file. Here is what i have so far.
#include #include #include using namespace std; void FileSubmit() { char *user="user"; char *pass="password"; char *ftpserver="ftp.server.com"; HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession, "C:\\test.txt", "file.txt", FTP_TRANSFER_TYPE_ASCII, 0) == TRUE){ cout << "File Sent! " << endl; Sleep(1000); InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); } else{ cout << "File didnt send " << endl; } } int main(){ FileSubmit(); return 0; }
I know text files need to be sent in ASCII mode so i switched to that and it still didnt work. It uploads the file but the file is empty. Whats going on??? Thanx in advance!dellthinker wrote:
But problem is that there is nothing in the text file.
So is the source file empty?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
dellthinker wrote:
But problem is that there is nothing in the text file.
So is the source file empty?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
DavidCrow wrote:
So is the source file empty?
Yes, as in 0 bytes. And how do i open it in passive mode? I didnt see an option for it.
-
DavidCrow wrote:
So is the source file empty?
Yes, as in 0 bytes. And how do i open it in passive mode? I didnt see an option for it.
dellthinker wrote:
And how do i open it in passive mode?
Use
INTERNET_FLAG_PASSIVE
flag fordwFlags
parameter.Regards, Vijay. God may not give us what we 'want', but he surely gives us what we 'need'.
-
dellthinker wrote:
And how do i open it in passive mode?
Use
INTERNET_FLAG_PASSIVE
flag fordwFlags
parameter.Regards, Vijay. God may not give us what we 'want', but he surely gives us what we 'need'.
Well that seemed to do the trick. However i ran Wireshark and it doesnt exactly request PASV before sending. *shrugs* We dont explain why it works that way. It just works! Thanx for your replies, i've been at it for ages and now i can finally move on to the next option task :)
-
DavidCrow wrote:
So is the source file empty?
Yes, as in 0 bytes. And how do i open it in passive mode? I didnt see an option for it.
dellthinker wrote:
Yes, as in 0 bytes.
So if the source file is
0
bytes and the destination file is0
bytes, what's the problem?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
dellthinker wrote:
Yes, as in 0 bytes.
So if the source file is
0
bytes and the destination file is0
bytes, what's the problem?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Sorry i read that wrong. The file on my machine was 1kb. And before i added the INTERNET_FLAG_PASSIVE argument it would upload the file, but on the ftp server it would be 0KB when the original file was 1kb