* * *

Author Topic: Download a file from the net  (Read 1145 times)

GetMem

  • Hero Member
  • *****
  • Posts: 2926
Re: Download a file from the net
« Reply #15 on: April 10, 2018, 03:55:22 pm »
"upload.php" and "test" folder should be in the same directory, namely your http server root folder. Make sure both the php file and the folder has enough privileges. If still not works check the value of SS.DataString:
Quote
//...
ShowMessage(SS.DataString) //add this line
Result := SS.DataString = 'zipok';
//...

You can download the openssl libraries from here:
32 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-i386-win32.zip
64 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-x64_86-win64.zip
Use the appropriate bitness and copy the dlls in the same folder with your exe.

justnewbie

  • Full Member
  • ***
  • Posts: 101
Re: Download a file from the net
« Reply #16 on: April 10, 2018, 06:59:53 pm »
Thank you, I will check this!

Zath

  • Sr. Member
  • ****
  • Posts: 272
Re: Download a file from the net
« Reply #17 on: April 16, 2018, 03:55:43 pm »
As a homework you can add a ProgressBar.

Sorry to jump in on your homework...

Code: Pascal  [Select]
  1. procedure TForm1.DoOnWriteStream(Sender: TObject; APosition: Int64);
  2. begin
  3.   Progressbar1.Position:=Progressbar1.Position+1;
  4.   Label1.Caption := 'Downloaded so far: ' + FormatSize(APosition);
  5.   Application.ProcessMessages;
  6. end;    
  7.  

Is that right ?
It's the only place I could get the bar to increase. However, somehow it needs the filesize and assign that as the Progresbar max.

I've been working on a very similar project so this thread is interesting.
« Last Edit: April 16, 2018, 11:12:24 pm by Zath »

GetMem

  • Hero Member
  • *****
  • Posts: 2926
Re: Download a file from the net
« Reply #18 on: April 16, 2018, 05:47:08 pm »
@Zath
Quote
It's the only place I could get the bar to increase. Is that right ?
Yes.

Quote
However, somehow it needs the filesize and assign that as the Progresbar max.
You can request the file size, if the server supports the feature.

PS: Alternatively use the built-in DoOnDataReceived event as in the attachment. Unfortunately there is no DoOnDataSent so for upload you still need the StreamClass from my previous post.
« Last Edit: April 16, 2018, 06:34:42 pm by GetMem »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus