Question

Could anyone please give a working example of how to upload a file using Delphi CGI.

I have googled but so far haven't had any luck.

This is what I have been trying but I am getting access violations.

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  lFileName   : string;
  lFileStream : TFileStream;
begin
  lFileName   := Request.Files[0].FileName;
  lFileStream := TFileStream.Create(lFileName, fmCreate);
  try
    lFileStream.CopyFrom(Request.Files[0].Stream, Request.Files[0].Stream.Size);
  finally
    lFileStream.Free;
  end;
end;

No correct solution

OTHER TIPS

Use idRunner components that you can find at:

http://www.vclcomponents.com/Delphi/Winsock___Internet/idRunner-info.html

They are free and include source code so you can adapt them.

I've used the code from the following link to make my webbroker stuff do (multi-)file uploads.

http://exposureroom.com/members/skumar.aspx/tutorials/post/18

The site has a lot of information on how to do things with the webbroker technology.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top