DelphiRulez
asked on
Updating Textfile on FTP Server or HTTP Server
I need to use Indy components to update a file on the internet.
I will have a text file placed on a FTP server or HTTP Server (which ever method is the securist and/or easist to do). I would like my application to logon, check for existence of file and if its there, append some data to it. All the data will be in Comma delimited text (one string).
Can one one help me please?
Code please?
I will have a text file placed on a FTP server or HTTP Server (which ever method is the securist and/or easist to do). I would like my application to logon, check for existence of file and if its there, append some data to it. All the data will be in Comma delimited text (one string).
Can one one help me please?
Code please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well... the file exists on the server that you want to change or rename or do something with, correct? This file resides on an HTTP server or FTP server, correct?
Then you must have a client application that connects to your FTP server to get the file, change the file, delete the file and etc.
The demos also have an example of using Indy to grab a file off of an HTTP (web) server as I recall. Again this would be a client application.
In any event, your application will be a client.
The FTP client demo shows you how to use all of the IndyFTP components to do pretty much everything you want to do by your post using FTP, file transport protocol.
John
Then you must have a client application that connects to your FTP server to get the file, change the file, delete the file and etc.
The demos also have an example of using Indy to grab a file off of an HTTP (web) server as I recall. Again this would be a client application.
In any event, your application will be a client.
The FTP client demo shows you how to use all of the IndyFTP components to do pretty much everything you want to do by your post using FTP, file transport protocol.
John
Oh... by learning from the demo on how to use the FTP components, you can piece this all together in your own custom application.
ASKER
I already solved it on my own, using EE search results
See code below.....its just a segment of my actual code....but its working code incase others need it in the future
thanks for responding though
See code below.....its just a segment of my actual code....but its working code incase others need it in the future
thanks for responding though
var
F: TextFile;
begin
if not idFTP.Connected then
begin
try
idFTP.Connect;
if IdFTP.Connected then
begin
idFTP.ChangeDIr('/public_ftp/cz/');
IdFTP.Get('data.txt', 'data.txt', true, true);
IdFTP.Delete('data.txt');
AssignFile(F, 'data.txt');
Append(F);
WriteLn(F, GetPersonalInfo);
CloseFile(F);
IdFTP.Put('data.txt','data.txt',False);
DeleteFile('data.txt');
end
else
rchScreen.Lines.Add('Error connecting');
finally
IdFTP.Disconnect;
end;
end;
end;
try
idFTP.Connect;
your try should be below the connect
idFTP.Connect;
try
only if you succeed in connecting need you disconnect
the other way means you allways disconnect, even if you couldn't connect
which may also produce an error
btw, your code is following the guidelines of Johnjces
idFTP.Connect;
your try should be below the connect
idFTP.Connect;
try
only if you succeed in connecting need you disconnect
the other way means you allways disconnect, even if you couldn't connect
which may also produce an error
btw, your code is following the guidelines of Johnjces
ASKER
already found and corrected it, after i posted last night....but thanks
ASKER
"btw, your code is following the guidelines of Johnjces"
I believe I asked for code. "Code Please?" Not a link to demos. I had already looked at demos and none of them did what i wanted them to do.
I knew how to connect and disconnect and get a list of files and get and put a file on a FTP server.
I just couldn't figure out how to update a file (Append) as my question stated.......and it all boiled down to the removal of the file, both on the server and the harddrive.
Sorry, but i solved it on my own. If I thought he deserved the points, i would happily give it to him....I have unlimited to go around....since I pay for the service.
I believe I asked for code. "Code Please?" Not a link to demos. I had already looked at demos and none of them did what i wanted them to do.
I knew how to connect and disconnect and get a list of files and get and put a file on a FTP server.
I just couldn't figure out how to update a file (Append) as my question stated.......and it all boiled down to the removal of the file, both on the server and the harddrive.
Sorry, but i solved it on my own. If I thought he deserved the points, i would happily give it to him....I have unlimited to go around....since I pay for the service.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, but i needed it to work on either FTP or HTTP. FTP seems to be doing the job!
ASKER
I have decided to award the points to the two of you....becuase you two at least responded....and it should help someone else in the future.
Thanks
Thanks
ASKER
thanks for responding!