Solved

How to upload files via ftp in delphi?

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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