 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Flabbergasted Expert Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 231 Location: I have alzheimer's.
|
Posted: Tue Nov 25, 2008 1:25 am Post subject: [Delphi - help] How to upload via FTP? |
|
|
Hi, I'm trying to build a bug report in Delphi, I wanna save a memo in a text file, upload it via FTP and delete the file when it's done. I just want to know how to upload the file. Thanks.
Willing to +rep, been trying to figure this out for a really long time...
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Tue Nov 25, 2008 1:44 am Post subject: |
|
|
I really recommend this tutorial:
FTP with Delphi
http://www.example-code.com/delphi/ftp_upload.asp
_________________
Last edited by sponge on Tue Nov 25, 2008 1:53 am; edited 4 times in total |
|
Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Tue Nov 25, 2008 1:44 am Post subject: |
|
|
http://www.example-code.com/delphi/ftp.asp
edit: damnit sponge beat me to it. Oh well. Mine is the list. His is a topic on the list
_________________
Blog
Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
Back to top |
|
 |
Flabbergasted Expert Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 231 Location: I have alzheimer's.
|
Posted: Wed Nov 26, 2008 4:11 pm Post subject: |
|
|
I tried that, it doesn't work for me. I probably should have mentioned that . Here's the code I got:
Code: | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
CHILKATFTP2Lib_TLB,
OleCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ftp: TChilkatFtp2;
success: Integer;
localFilename: String;
remoteFilename: String;
begin
ftp := TChilkatFtp2.Create(Self);
// Any string unlocks the component for the 1st 30-days.
success := ftp.UnlockComponent('Anything for 30-day trial');
if (success <> 1) then
begin
ShowMessage(ftp.LastErrorText);
end;
ftp.Hostname := 'ftp.phpnet.us';
ftp.Username := 'pn_2661359';
ftp.Password := '*****';
// The default data transfer mode is "Active" as opposed to "Passive".
// Change it to Passive by setting the Passive property:
ftp.Passive := 1;
// Connect and login to the FTP server.
success := ftp.Connect();
if (success <> 1) then
begin
ShowMessage(ftp.LastErrorText);
end;
// Change to the remote directory where the file will be uploaded.
success := ftp.ChangeRemoteDir('lalala');
if (success <> 1) then
begin
ShowMessage(ftp.LastErrorText);
end;
// Upload a file.
localFilename := 'test.txt';
remoteFilename := 'test.txt';
success := ftp.PutFile(localFilename,remoteFilename);
if (success <> 1) then
begin
ShowMessage(ftp.LastErrorText);
end;
ftp.Disconnect();
ShowMessage('File Uploaded!');
end;
end. |
I got no errors whatsoever, but it doesn't upload
|
|
Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Nov 26, 2008 5:03 pm Post subject: |
|
|
Eww.. just eww... don't use Chilkat's FTP component, it's shit.
use Windows API.
here's a function i made:
Code: | function upload_file(remote_server, //by sloth
directory,
local_file,
remote_file,
user,
pass: PAnsiChar): boolean;
var hInet, hConnect: HINTERNET;
Dir, Put: Boolean;
begin
hInet := InternetOpen(nil, INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
hConnect := InternetConnect(hInet,
remote_server,
INTERNET_DEFAULT_FTP_PORT,
user, pass,
INTERNET_SERVICE_FTP,
INTERNET_FLAG_PASSIVE,
0);
Dir := ftpSetCurrentDirectory(hConnect, directory);
WaitForSingleObject(Cardinal(Dir), infinite);
Put := ftpPutFile(hConnect, local_file, remote_file, FTP_TRANSFER_TYPE_BINARY, 0);
InternetCloseHandle(hInet);
InternetCloseHandle(hConnect);
Result:= Put;
end; |
Flabbergasted: the line Passive := 1, do you know what it is ? according to his shitty component, it's for the SSL usage, remove that line to make it work.
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|