Hello,
Thats my first post, but I did some research before posting.
I need function (or procedure, whatever).
I installed synapse, and INDY 10, I'm using Delphi 7.
Searched here and there and I modyfied this code posts:
clickThere's no problem whet url is just standard HTTP, but when its HTTPS it give 500 code.
I add ssl_openssl, ssl_openssl_lib to uses, as was adviced at some thread at this forum. (Can't find it right now)
Can anyone help me out and modify this code for HTTPS to works?
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, httpsend, IdHTTP, IdStack, ssl_openssl, ssl_openssl_lib ;
function pobierzzsieci(URL: string; FileName: string): boolean;
var
httpClient: THTTPSend;
noErrors: boolean;
Path: string;
begin
noErrors:= True;
httpClient := THTTPSend.Create;
if httpClient.HTTPMethod('GET', URL) then
begin
// for windows
FileName := StringReplace(FileName, '/', '\',[rfReplaceAll, rfIgnoreCase]);
Path := IncludeTrailingPathDelimiter(GetCurrentDir) + FileName;
if httpClient.ResultCode = 200 then
begin
if not DirectoryExists(ExtractFilePath(Path)) then ForceDirectories(ExtractFilePath(Path));
httpClient.Document.SaveToFile(path);
end
else
noErrors := False;
end
else
begin
showmessage('something wrong code other than 200');
noErrors := False;
end;
Result := noErrors;
//Result:=httpClient.ResultCode ;
httpClient.Free;
end;
And
procedure TForm1.Button1Click(Sender: TObject);
var
url3: string;
plik: string;
begin
plik:='aaa\nowy\testowy\plik001.jpg';
url3:='https://kurdubelski.pl/images/avatar.jpg';
if pobierzzsieci(url3,plik) then label1.Caption:='pobrano '+url
else showmessage('theres no such file');
end;