Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   post Upload via Lazarus (https://www.delphipraxis.net/161907-post-upload-via-lazarus.html)

1234567890987654321 26. Jul 2011 23:46

post Upload via Lazarus
 
Hallo.

Ich habe eine Datei, welche ich in ein Onlineformular (php) hochladen will:
Normalerweise kann ich das in Firefoy ganz einfach bewerksteligen (Datei auswählen > Upload).

Gibt es irgendeine Function (z.B. in Synapse) mit der ich einen Post-Upload zu einem PHP-Script machen kann?

Ich hoffe ihr habt meine Frage verstanden.
Danke fürs Lesen.

P.S: das Programm soll für Linux werden.

marcoX 26. Jul 2011 23:52

AW: post Upload via Lazarus
 
Delphi-Quellcode:

uses httpsend; //Synapse

function TForm1.UploadFile(Filename:string):TStrings;
var
Data:TFileStream;
FormFields:TStrings;
res:TStrings;
begin

Data:=TFileStream.Create(FileName, fmOpenRead);

FormFields:=TStringList.Create;
FormFields.Add('user='+edit1.text); //<input> oder hidden Values
FormFields.Add('upload=1'); //<input> oder hidden Values

Res:=TStringList.Create;

HttpPostFileForm('http://www.example.com/upload.php',
  'FormName', //Name des <form> Feldes
  ExtractFileName(FileName),
  Data,
  FormFields,
  res);

result:=res;

Data.Free;
FormFields.free;

end;

1234567890987654321 27. Jul 2011 00:54

AW: post Upload via Lazarus
 
Danke


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:26 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz