Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread EWB Server Fileupload
Fri, May 8 2015 11:04 AMPermanent Link

Peter W

Can I use the EWB server with the file upload.
Is there an example. The formsubmit example, does not transfer any file with me.
Or how can I select an image and save it to a DBISAM Blob field.
--

Peter Wuerstle
Mon, May 11 2015 7:18 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< Can I use the EWB server with the file upload.  Is there an example. The
formsubmit example, does not transfer any file with me. >>

The formsubmit *does* transfer the file, but you have to have a server
module on the web server end that does something with the file that has been
uploaded.  Otherwise, it simply is discarded.

I'll have to work up an example for you, but it's going to take a while.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, May 11 2015 10:42 AMPermanent Link

Ronald

Hi Peter,

I use Webbroker (this creates a .exe as application server) and the upload
action I use in the application server is:

uses ReqMulti;

procedure TWebModule1.WebModule1uploadAction(Sender: TObject;
 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
mpcp            :TMultiPartContentParser;
lsFileName,n    :string;
begin
mpcp:=TMultiPartContentParser.Create(Request);
with mpcp  do
   begin
   for i := 0 to Request.Files.Count -1 do
      begin
      lsFileName:=Request.Files[i].FileName;
      n:=ExtractFileName(lsFileName);
      TMemoryStream(Request.Files[i].Stream).SaveToFile(aPathName+'\'+n);
      end;
   Response.Content := 'OK';
   end;
mpcp.Free;
end;

This works fine in XE2.

Hope that it works for you.

Greetings,
Ronald

"Peter Wuerstle" schreef in bericht
news:EFEFBD17-6556-467E-B3A3-E0603C932A00@news.elevatesoft.com...

Can I use the EWB server with the file upload.
Is there an example. The formsubmit example, does not transfer any file with
me.
Or how can I select an image and save it to a DBISAM Blob field.
--

Peter Wuerstle
Mon, May 11 2015 5:37 PMPermanent Link

Paul Waegemans

IMS

Tim,
I'am very interested in this issue.  I hope the example will appear soon.

I want to give my users the possibility to upload files to te server.

Paul Waegemans.


"Tim Young [Elevate Software]" wrote:

The formsubmit *does* transfer the file, but you have to have a server
module on the web server end that does something with the file that has been
uploaded.  Otherwise, it simply is discarded.

I'll have to work up an example for you, but it's going to take a while.
Thu, May 28 2015 7:03 AMPermanent Link

Peter W

Hi Ronald,

thanks for the advice, now I use the following code in the server modules.

procedure TEWBModule1.EWBModuleExecute(Request: TEWBServerRequest);
var
bild:TMemoryStream;
begin

  tbl.insert;

   if Request.RequestMIMEParts.Count = 1 then   // only 1 Image is send
   begin
      bild:=TMemoryStream.Create;
     try
       Request.RequestMIMEParts[0].Save(bild);
       TBlobField(tbl.FieldByName('Bild')).LoadFromStream(bild);
       Request.SendContent('OK');
     finally
       bild.Free;
     end;
   end;

   tbl.Post;
end;

Greetings Peter


"Ronald" wrote:

Hi Peter,

I use Webbroker (this creates a .exe as application server) and the upload
action I use in the application server is:

uses ReqMulti;

procedure TWebModule1.WebModule1uploadAction(Sender: TObject;
 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
mpcp            :TMultiPartContentParser;
lsFileName,n    :string;
begin
mpcp:=TMultiPartContentParser.Create(Request);
with mpcp  do
   begin
   for i := 0 to Request.Files.Count -1 do
      begin
      lsFileName:=Request.Files[i].FileName;
      n:=ExtractFileName(lsFileName);
      TMemoryStream(Request.Files[i].Stream).SaveToFile(aPathName+'\'+n);
      end;
   Response.Content := 'OK';
   end;
mpcp.Free;
end;

This works fine in XE2.

Hope that it works for you.

Greetings,
Ronald

"Peter Wuerstle" schreef in bericht
news:EFEFBD17-6556-467E-B3A3-E0603C932A00@news.elevatesoft.com...

Can I use the EWB server with the file upload.
Is there an example. The formsubmit example, does not transfer any file with
me.
Or how can I select an image and save it to a DBISAM Blob field.
--

Peter Wuerstle
--

Peter
Tue, Feb 20 2018 2:27 AMPermanent Link

Paul Waegemans

IMS bvba

Avatar

After trial and error I came to the following code in module that runs serverside and  that works fine:


for i := 0 to Request.RequestMIMEParts.Count -1 do
          begin
          lsFileName:=Request.RequestMIMEParts[i].FileName;
          n:=documentenmap+ExtractFileName(lsFileName);
          MyFile := FileCreate(n);
          TempFileStream:=TFileStream.Create(MyFile);
          Request.RequestMIMEParts[i].Save(TempFileStream);
          TempFileStream.free;
          TempFileStream:=nil;
          end;


"Ronald" wrote:

Hi Peter,

I use Webbroker (this creates a .exe as application server) and the upload
action I use in the application server is:

uses ReqMulti;

procedure TWebModule1.WebModule1uploadAction(Sender: TObject;
 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
mpcp            :TMultiPartContentParser;
lsFileName,n    :string;
begin
mpcp:=TMultiPartContentParser.Create(Request);
with mpcp  do
   begin
   for i := 0 to Request.Files.Count -1 do
      begin
      lsFileName:=Request.Files[i].FileName;
      n:=ExtractFileName(lsFileName);
      TMemoryStream(Request.Files[i].Stream).SaveToFile(aPathName+'\'+n);
      end;
   Response.Content := 'OK';
   end;
mpcp.Free;
end;

This works fine in XE2.

Hope that it works for you.

Greetings,
Ronald

"Peter Wuerstle" schreef in bericht
news:EFEFBD17-6556-467E-B3A3-E0603C932A00@news.elevatesoft.com...

Can I use the EWB server with the file upload.
Is there an example. The formsubmit example, does not transfer any file with
me.
Or how can I select an image and save it to a DBISAM Blob field.
--

Peter Wuerstle
Image