Solved

How to upload files via ftp in delphi?

Posted on 2011-03-04
5
1,139 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

Independent Software Vendors: 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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Network ports are the threads that hold network communication together. They are an essential part of networking that can be easily ignore or misunderstood, my goals is to show those who don't have a strong network foundation how network ports opera…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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