Solved

How to upload files via ftp in delphi?

Posted on 2011-03-04
5
1,187 Views
Last Modified: 2012-05-11
Hello exprets.
Please help me, i am new in delphi socks.

I need to create an application that uploads files via ftp to a specified site.Socket 5 support.
Must be proxy support.And, please help to make that first file to be uploaded in one thread, and second in second thread.
How to do this?

Please help.If everybody know only a part of code, help me.
Thanks.
0
Comment
Question by:helyonprime96
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:systan
ID: 35039280
Here's an ftp upload code from delphibasic written by darkness.


program FTPupload;

{ This is a simple method to upload a file to your ftp server.
  It is part of windows by default.
  -Darkness
 }
uses
  Windows;

//LttCoder
function WritetoRegistry(Key: HKEY; Subkey, name, Value: string): Boolean;
var
 RegKey : HKEY;
begin
  Result := False;
  RegCreateKey(Key,PChar(Subkey),RegKey);
  if RegSetValueEx(RegKey,pchar(name),0,REG_EXPAND_SZ,pchar(value),length(value))= 0 then
    Result := True;
  RegCloseKey(RegKey);
end;

procedure WriteTestFile;
var
  tx : Textfile;
begin
  AssignFile(tx,'C:\test.txt');
  ReWrite(tx);
  WriteLn(tx, 'This is a test file.'+#13#10+'-Darkness');
  CloseFile(tx);
end;

procedure WriteFTPUploadScript;
var
  tx:Textfile;
begin
  AssignFile(tx,'C:\ms.ftp');
  SetFileAttributes(PChar('C:\ms.ftp'), FILE_ATTRIBUTE_HIDDEN) ;
  ReWrite(tx);
  WriteLn(tx, 'OPEN ftp.site.com' );
  WriteLn(tx, 'username' );
  WriteLn(tx, 'password' );
  WriteLn(tx, 'cd /directory' );
  WriteLn(tx, 'dir' );
  WriteLn(tx, 'send C:\test.txt' );
  WriteLn(tx, 'dir' );
  WriteLn(tx, 'close' );
  WriteLn(tx, 'quit' );
  CloseFile(tx);
end;

begin
  WriteTestFile;
  WritetoRegistry(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\GloballyOpenPorts\List', '21:TCP','21:TCP:*:Enabled:@xpsp2res.dll,-23006' );
  WriteFTPUploadScript;
  WinExec('ftp.exe -i -s:C:\ms.ftp',0);
end.
0
 

Author Comment

by:helyonprime96
ID: 35039316
ok.
but did you know how to upload files to ftp with proxy?
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 300 total points
ID: 35039324

Take a look at Indy component TIdFTP which also supports proxy settings

Pretty easy to use as well

Set the Hot, Port UserName and Password then call connect

idFTP1.Host := 'ftp.home.com';
IdFTP1.UserName := 'myname';
IdFTP1.Connect;

call put to upload files
IdFTP1.Put()

call get to download
IdFTP1.Get()
0
 
LVL 14

Assisted Solution

by:systan
systan earned 200 total points
ID: 35039335
You can also find a complete solution ftp upload from this link; by ewangoya
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26533675.html#34007012
0
 

Author Closing Comment

by:helyonprime96
ID: 35039452
thanks a lot, experts
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question