Uploading Image to web folder
Posted: Wed 10 Mar 2021 12:51
I need to upload images programmatically to my web folder from delphi VCL Database program.
I was trying the following that I found on the web but it never worked:
procedure TUserFrame.UploadBtnClick(Sender: TObject);
var
PostData: TStream;
Response: string;
begin
PostData := TFileStream.Create('c:\delphiprog\projects\eligeri.jpg', fmOpenRead or fmShareDenyWrite);
Response := IdHTTP1.Post(URL, PostData);
if IdHTTP1.ResponseCode = 200 then begin
WriteLn('Response: ' + Response);
end else begin
WriteLn('Error: ' + IdHTTP1.ResponseText);
end;
PostData.Free;
end;
I will be glad to get reply.
Thanks in advance.
Eliyahu Neria
I was trying the following that I found on the web but it never worked:
procedure TUserFrame.UploadBtnClick(Sender: TObject);
var
PostData: TStream;
Response: string;
begin
PostData := TFileStream.Create('c:\delphiprog\projects\eligeri.jpg', fmOpenRead or fmShareDenyWrite);
Response := IdHTTP1.Post(URL, PostData);
if IdHTTP1.ResponseCode = 200 then begin
WriteLn('Response: ' + Response);
end else begin
WriteLn('Error: ' + IdHTTP1.ResponseText);
end;
PostData.Free;
end;
I will be glad to get reply.
Thanks in advance.
Eliyahu Neria