Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP and listing files on server

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
Does anyone have any sample code for the FTP'ing of files ?
When the user enters the appropriate user name and password I'll like to be able to provide them with the ability of FTP'ing files onto the web server.
Can it be done such that I am able to make use of Directory List boxes such that the user can see the folders + files on the server and copy / move files about accordingly ? Similarly there will be a need for the copying of files from the local workstation to the web server to the indicated directory.
Any help / pointers would be appreciated.
Thanks in advance.
Steve
 
The problem with listing files, is that you can retrieve a number of different file listings.. Unix, MSDOS and so on...

Anyway, I tried to do a FTP connection with a simple Winsock component, but it wasx too much work to get it bug free. Because you have to open a dataconnection and ask for the listing i a file format... E.g. you retrieve the filelisting as a file, and then you have to decode it depending with format it is...

I recommend that you use Indy FTP components, or something similar...
 
Is there any way of achieving what I want to using standard Delphi components ?
I use Delphi 5.
Any helpers ?
Steve
 
If you like you can even go for real low level winsock programmin', but I would recommend, as Nordlund did to go for Indy components, as it's included in D6, and available free of charge. It will save you a headace or two, trying to debug the darn thing, Indy has already been in use for some time, and was known before as WinShoes.

The best help you can get is from the pros, get Indy.
(Shameless plug) ;-)

HTH, TonHu
 
That's another vote for the components as mentioned.
However we only have Delphi 5 at our disposal.
Can the above be achieved using D5 without the additional components as mentioned ?
Any thoughts ?
Steve
 
If you have to be that persistent: Use the wacky TNMFTP component on the FasyNet tab. This is from the helpfile on the List method:
<snip>
Applies to
TNMFTP component

Declaration
procedure List;

Description
The List method is used for getting a list of files and directories from the remote host. The listing retrieved is for the current working directory.

Notes:
For each item listed, the OnListItem event is called.
If the ParseList property is set to TRUE, the FTPDirectoryList property will contain the elements for each listing, including name, size, and attributes.
If this command succeeds, the OnSuccess event will be called, otherwise the OnFailure event is called. In either case, cmdList is passed as the Trans_Type parameter in the event.
</snip>

Be prepared to work around some bugs or other 'undesired' workings of these crappy components! Bon't say we didn't warn you [roll2]

HTH, TonHu
 
Another soultion is WinInet. It's quite simple to do this with the functions FtpFindFirstFile and InternetFindNextFile.
The problem is that it works only with some sites, for instance InternetConnect won't connect to ftp.microsoft.com (it says it can't resolve the hostbame). If you know why please reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top