idFTP uploading files but cannot be downloaded through browser

Giganews Newsgroups
Subject: idFTP uploading files but cannot be downloaded through browser
Posted by:  Codeman II (thegentlem…@webmail.co.za)
Date: Thu, 13 Oct 2005

Hi there,

I am using idFTP for uploading updates of my software I develop.
There is 2 files that get uploaded:
1. update.ini (containing the verion info etc)
2. app_update.exe (the actual exe)

I have build an application that must upload these files to my webspace.
But the problem is that after the files have been uploaded successfully I
can not access them through the URL. Although if I connect with my FTP
client software (FileZilla / CuteFTP) the files do exist in the uploaded
directory. This is really weird. In CuteFTP I can download these files to my
HDD and the contents is correct. But for ex if I type the entire URL of the
files in my IE it can not found the page. As if the URL is invalid. How can
this be???

What I thought was that I must do some SPECIAL disconnect with idFTP to
submit or close the connection properly. But if the files get uploaded in
any case then how can something being wrong with my code? This is basically
what I did:

--------------CODE BEGIN-------------
procedure TfrmMain.tbUploadClick(Sender: TObject);
var
  RemoteFileName, Par :String;
  Ini :TIniFile;
begin
  With dtmMain do
  begin
    If tblApplications.IsEmpty then
    begin
      MessageDLG('No application selected.', mtInformation, [mbOk], 0);
      Exit;
    end;
    If IsInternetConnected = ctNone then
    begin
      MessageDLG('Please dial your internet connection before continue.',
mtInformation, [mbOk], 0);
      Exit;
    end;

    PJVersionInfo.FileName := tblApplicationsLocalPath.Value;
    frmNewIni.edtFileVersion.Text := PJVersionInfo.FileVersion;
    frmNewIni.edtFileSize.Text :=
IntToStr(Round(GetFileSize(tblApplicationsLocalPath.Value) / 1000));
    If frmNewIni.ShowModal = mrOk then
    begin
      //If file need to be compress then
      Par := '-9 ' + '"' + tblApplicationsLocalPath.Value + '"';
      ShellExecuteAndWaitToComplete('"' + frmMain.AppPath + 'upx.exe"', Par,
'');
      //New file size after compressing
      frmNewIni.edtFileSize.Text :=
IntToStr(Round(GetFileSize(tblApplicationsLocalPath.Value) / 1000));

      //First or create the Ini file;
      If FileExists(frmMain.AppPath + 'temp.ini') then
        DeleteFile(frmMain.AppPath + 'temp.ini');
      Ini := TIniFile.Create(frmMain.AppPath + 'temp.ini');
      Ini.WriteString(tblApplicationsName.Value, 'version',
frmNewIni.edtFileVersion.Text);
      Ini.WriteString(tblApplicationsName.Value, 'size',
frmNewIni.edtFileSize.Text);
      Ini.WriteString(tblApplicationsName.Value, 'bugs',
frmNewIni.memBugs.Text);
      Ini.WriteString(tblApplicationsName.Value, 'changes',
frmNewIni.memChanged.Text);
      Ini.WriteString(tblApplicationsName.Value, 'new',
frmNewIni.memNew.Text);

      //Login via FTP
      idFTP.Disconnect;
      idFTP.Host := tblApplicationsFTPHost.Value;
      idFTP.Username := tblApplicationsFTPUsername.Value;
      idFTP.Password := tblApplicationsFTPPassword.Value;
      idFTP.Connect(True, 10000);
      Try
        //Upload (FTP) Exe file
        idFTP.Put(tblApplicationsLocalPath.Value,
ExtractFileName(tblApplicationsRemotePath.Value), False);
        //Upload (FTP) ini File
        idFTP.Put(frmMain.AppPath + 'temp.ini',
tblApplicationsIniRemotePath.Value, False);

        If FileExists(frmMain.AppPath + 'temp.ini') then
          DeleteFile(frmMain.AppPath + 'temp.ini');
      Finally
        idFTP.Quit;
        idFTP.Disconnect;
      end;
    end;
  end;
end;
--------------------CODE END-------------------------

Can anyone show me a simple A) Connect B) Put File C) and Disconnect with
idFTP which will work for uploading multiple files as well.

Thanks in advance.

Replies