How to download a file with sending POST? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- M[a]nny · 2013-04-06 01:47 I've seen this function on the forum: Code: [Select]procedure DownloadFile(const Url, PathToSaveTo: string); var   fs: TFileStream; begin    fs := TFileStream.Create(PathToSaveTo, fmOpenWrite or fmCreate);    try       HttpGetBinary(Url, fs);    finally       fs.Free;    end; end;  But how to make a POST requiest in it? I want to send a HTML file and get as result PDF file (my php script can handle it). ---------------------------------------------------------------------- Silvio Clécio · 2013-04-06 02:19 Hello, Know Brook framework (http://brookframework.org), downloading current version in: https://github.com/silvioprog/brookframework/archive/master.zip So, you can do it easily, e.g: Code: [Select]uses   BrookHTTPClient, BrookFCLHTTPClientBroker, BrookHTTPConsts; procedure TForm1.Button1Click(Sender: TObject); var   VHttp: TBrookHTTPDef;   VClient: TBrookHTTPClient; begin   VClient := TBrookHTTPClient.Create('fclweb');   try     VClient.Prepare(VHttp);     VHttp.Url := 'your-url';     VHttp.Method := BROOK_HTTP_REQUEST_METHOD_POST;     VHttp.Contents.LoadFromFile('your-file.html');     if VHttp.Request then       VHttp.Contents.SaveToFile('your-file.pdf')     else       ShowMessageFmt('ERROR: code: %d, text: %s, content: %s',         [VHttp.StatusCode, VHttp.ReasonPhrase, VHttp.Contents.Text]);   finally     VHttp.Free;     VClient.Free;   end; end; Good luck! ---------------------------------------------------------------------- M[a]nny · 2013-04-06 04:24 Thank you very much but can you tell me how to get the HTML file in server-side PHP script? I mean, okay, i sent it to server but i don't know how to work with it. Can you make a simple example for me to show how to gain file content in PHP server-side script, please? ---------------------------------------------------------------------- Leledumbo · 2013-04-06 05:53 QuoteThank you very much but can you tell me how to get the HTML file in server-side PHP script?http://php.net/manual/en/reserved.variables.files.php There's also a link there explaining how to handle file uploads ---------------------------------------------------------------------- Silvio Clécio · 2013-04-06 06:24 Hm... I don't know if it would be interesting talk about PHP, but ... A thousands years ago, when I worked with PHP, I used this script to send uploads: http://www.sendspace.com/file/zt9dqa ---------------------------------------------------------------------- Leledumbo · 2013-04-06 07:16 QuoteA thousands years ago, when I worked with PHP, I used this script to send uploads:I think he asked how to handle the uploaded file, not sending it. ---------------------------------------------------------------------- M[a]nny · 2013-04-06 15:14 QuoteI think he asked how to handle the uploaded file, not sending it.That's it. ---------------------------------------------------------------------- Silvio Clécio · 2013-04-06 17:01 Oops, sorry. ---------------------------------------------------------------------- M[a]nny · 2013-04-08 05:36 I am sorry that i am asking again but i am trying to receive the file with this code: Code: [Select] It should take sent file and save it to "upload/my_sent_file.html" but it does nothing. Does anybody know where is the problem? I am out of ideas... ---------------------------------------------------------------------- Leledumbo · 2013-04-08 11:58 QuoteIt should take sent file and save it to "upload/my_sent_file.html" but it does nothing.Is the echo on if part executed? Do your application has permission to write to that directory? Could you try absolute path for destination? ---------------------------------------------------------------------- Silvio Clécio · 2013-04-08 14:56 Hey boss, so you is trying to send it via upload! Please try this sample: http://www.sendspace.com/file/p3j6ks Open and run, it uses my host for tests. ---------------------------------------------------------------------- M[a]nny · 2013-04-09 20:53 Thank you very much, sir. You have my respect It works like a charm.