indy ftp ile dosya tranferi yapmak istiyorum fakat "RETR" comand not implemented ikazı alıyorum ve sadece client tarafına dosya oluşturuluyor.
ama içi boş.hem ftp client programı hemde ftp server programı kendi bilgisayarımda çalıştırıyorum.bu problem cıkarırmı?
changedir ve list komutlarını kabul etmiyor hata veriyor.
makine:tidftpclient
try
DosyaListesi:=TStringList.Create;
makine.host:=192.168.1.9
if FtpBaglan=true then
begin
// makine.ChangeDir('c:\program files');
edit1.Text:=Makine.RetrieveCurrentDir;
Application.ProcessMessages;
DirectoryListBox1.Items.Clear;
Makine.List(DosyaListesi); //burdan sonra hata veriyor
ListBox1.Assign(DosyaListesi);
DirectoryListBox1.Items.Assign(DosyaListesi);
if DirectoryListBox1.Items.Count > 0 then
begin
makine.TransferType:=ftASCII;
Makine.Get(DownloadYolu+'Metinsore.ini',ExtractFilePath(Application.ExeName) + 'bin\MetinStore.ini',true,true);
end;
end;
except
//
end;
end;
ben bunu ftp serverde fotograf tutmak ve gerektigi zaman cliente almak icin kullaniyorum insallah isinize yarar
directorychandir li yapamamistim ve bu yolu denedim
//ftp servere baglanmak icin
procedure SetFtpInfo();
begin
if f_open.IdFTP1.Tag = 0 then
begin
DM.q_dej.Close;
DM.q_dej.SelectSQL.Text := 'select first 1
ftp_adres, ftp_user, ftp_password, ftp_path from mypoint';
DM.q_dej.Open;
f_open.idftp1.Host := DM.q_dej.Fields[0].Value; //192.168.20.215
f_open.idftp1.Username := DM.q_dej.Fields[1].Value; //assa
f_open.idftp1.Password := DM.q_dej.Fields[2].Value; //assa
f_open.Label17.Caption := DM.q_dej.Fields[3].Value; //./foto/ (ftp yolu)
DM.q_dej.Close;
f_open.idftp1.Tag := 1;
end;
end;
//file varmi yokmu control ediyor
function FtpFileExists(AFTP: TIdFTP; const APath: string): Boolean;
begin
Result := AFTP.Size(APath) <> -1;
end;
//for put servere kaydetmek icin
procedure Tf_open.BitBtn1Click(Sender: TObject);
var
strim: TMemoryStream;
jpeg: TjpegImage;
flpath: string[80];
begin
Image1.Picture.Assign(nil);
if not dm.db.Connected then exit;
if DM.q_rayat.Fields[0].Value = null then exit;
if not OpenPictureDialog1.Execute then exit;
if Length(Trim(OpenPictureDialog1.FileName)) = 0 then exit;
SetFtpInfo(); //baglanmak icin cagyryyor
//nereye kaydedejegini belirtiyorus flpath:=Label17.Caption+AnsiLowerCase(DM.q_rayat.Fields[0].Value)+'.jpg';
if not idftp1.Connected then idftp1.Connect(True, 100);
strim := TMemoryStream.Create; jpeg := Tjpegimage.Create;
jpeg.LoadFromFile(OpenPictureDialog1.FileName);
Image1.Picture.Bitmap.Assign(jpeg);
strim.Free; jpeg.Free;
if Application.MessageBox(PChar('Servere Kaydetmelimi ?'), PChar('Soru'), mb_YesNo + mb_IconQuestion) <> mrYes then begin
Image1.Picture.Assign(nil);
exit;
end;
if FtpFileExists(idftp1, flpath) then idftp1.Delete(flpath);
idftp1.Put(OpenPictureDialog1.FileName, flpath, True);
if idftp1.Connected then idftp1.Disconnect();
MessageDlg('Kaydettim', mtInformation, [mbOk], 0);
Image1.Picture.Assign(nil);
end;
//for get file
procedure Tf_open.BitBtn2Click(Sender: TObject);
var
strim: TMemoryStream;
jpeg: TjpegImage;
flpath: string[80];
begin
Image1.Picture.Assign(nil);
//Label18.Caption:='-';
if not dm.db.Connected then exit;
if DM.q_rayat.Fields[0].Value = null then exit;
SetFtpInfo(); //baglanmak icin
//ftp yolu yani nerden aljak
flpath := Label17.Caption + AnsiLowerCase(DM.q_rayat.Fields[0].Value) + '.jpg';
if not idftp1.Connected then idftp1.Connect(True, 100);
if not FtpFileExists(idftp1, flpath) then begin
Image1.Hint := flpath;
Showmessage('foto yok');
exit;
end;
strim := TMemoryStream.Create; jpeg := Tjpegimage.Create;
//strim yerine nereye kaydedejegini yazabilirsin yani client
idftp1.Get(flpath, strim);
strim.Seek(0, 0);
jpeg.LoadFromStream(strim);
Image1.Picture.Bitmap.Assign(jpeg);
strim.Free; jpeg.Free;
if idftp1.Connected then idftp1.Disconnect();
end;
@mrmarman yazdı:Şimdilik sizin için code bloğuna ben aldım. Lütfen kodlarınızı okunur şekilde yazınız. Yazdıktan sonra bloklayarak Code yazan butona basınız. Bu şekilde formatlı bir şekilde forumda görünecektir. @mrmarman