I am using Delphi 7 personal along with Indy 10.
I have a program that uploads a 7 mb .dat file to a remote server thru ftp. I have my code wrapped into a try/except but for some reason and at some point, the transfer fails, and i get no errors or exceptions whatsoever. I am even getting the message 'dat file uploaded!' to show up.
Only i get a .dat file uploded on the remote server but that hasn't the size of the original one.
I tried uploading the same file manually with my ftpcore, and it worked ok. So i guess there might be something wrong with my code?

here it is :

 if FileExists(myFile) then
  ftp.Port := 21;
  ftp.Passive := True;
      if FTPFileExists(myFile2) then
      showmessage('remote file exists already!');
      ftp.Put(myFile, '/htdocs/dat/remote_file.dat', true);
      showmessage('dat file uploaded!');
     on E : Exception do
     showmessage('transfer failed');

Thanks in advance

Well, as no one else is responding...

I'm not going to spend a lot of time looking through the Indy 10 documentation (which is fairly massive) and I don't know that much about FTP.

Are you transferring in binary mode?

You should try to catch the exact exceptions raised on errors.

The ftp.disconnect; should be after the except..end block, so that you are sure to disconnect even if an exception does occur. (It is OK to call disconnect if you are not connected.)

Hope this helps.

Hi, thanks for your reply,

Since my post, i have found that whenever i'm trying to use ftp.ResumeSupported, my program stops and then i'm getting an exception. So i figured that maybe the problem is server side as the free host i am using may not support transfer resuming.

So far i haven't been able to find this info in their documentation, although i have tried a few different hosts, set transfer type to ftBinary too, and well, i may successfully upload small .dat files i can never get to upload large .dat file, assuming that 7 megs is to be considered large.

So, i am going to try and catch exceptions raised on errors this time, and place disconnect after the except and see what it does.

Many thanks for your advice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.