[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

PutFile function is failing(synchronous mode)

In the Below code Putfile function is failing, and GetLastError is saying that File is not found. But i have the file in my local system, I want to upload that file to FTP server.

Thank you.

CInternet sess;
CFtpConnection* pConnection = NULL;
try
{
pConnection = sess.GetFtpConnection("EMM_PDC","administrator","tema");
            if(pConnection->SetCurrentDirectory("EMMCDROM"))
{
  if(pConnection->PutFile("C:\\test.html","test.html"))
  AfxMessageBox("Success");//DbgMsg("Out put path %s filename=%s filepath=%s ",outpath,filename,filepath);
else
{
AfxMessageBox("Failure");//DbgMsg("File transfer failed %d",GetLastError());
return FALSE;
}
}
else
{
AfxMessageBox("Setting current directory in FTP Server failed.");
return FALSE;
}
}
catch (CInternetException* pEx)
{
TCHAR buffer[1024];
pEx->GetErrorMessage(buffer,1024);
AfxMessageBox("InternetException");
pEx->Delete();
pConnection = NULL;
return FALSE;
}
0
jabarooth
Asked:
jabarooth
  • 5
1 Solution
 
jabaroothAuthor Commented:
Edited text of question.
0
 
jabaroothAuthor Commented:
Edited text of question.
0
 
RAVIDCommented:
HI
since FTP won't recognize the file extention to be 4 characters so remove test.html and put test.htm and you will get success

u have written
 if(pConnection->PutFile("C:\\test.html","test.html"))

u should write

 if(pConnection->PutFile("C:\\test.htm","test.htm"))

Regards
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
jabaroothAuthor Commented:
Hi,
Thank you for reply, i tried the samething before it is giving the same error. When i try to execute the FTPTREE sample given in VC++ CD for uploading, it is giving access denied error. But in GetFTPConnection function i passed administrator account. Is there any other kind of rights i need for uploading the file in the server side.

Thank you.
0
 
jabaroothAuthor Commented:
Hi
I can able to open the file in the Remote FTP server and also i can read that file. Problem is during uploading.

Thank you
0
 
jabaroothAuthor Commented:
Hi
I can able to open the file in the Remote FTP server and also i can read that file. Problem is during uploading.

Thank you
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now