Solved

How to upload files via ftp in delphi?

Posted on 2011-03-04
5
1,076 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
  • 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:
ewangoya 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now