Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWFileUploader OnAsyncUploadCompleted question
In the documentation at, it says for OnAsyncUploadCompleted it says

Quote:This event is triggered when the file upload completes, BEFORE it is processed or saved by IntraWeb core. You should use this event to save the file to a different location, under a different name, or save it to a blob field in a TDataSet component

The method signatures make perfect sense, but there is no mention how I would grab the uploaded file stream to save it to a blob field before saving it to disk.
Hi Dave,

Here it goes. This was extracted from one of our demos here:

procedure TIWForm51.IWFileUploader1AsyncUploadCompleted(Sender: TObject; var DestPath,
 FileName: string; var SaveFile, Overwrite: Boolean);
 MS: TMemoryStream;
 // Create any TStream descendant
 MS := TMemoryStream.Create;
   // Save the file content to that stream
   IWFileUploader1.SaveToStream(FileName, MS);
   // inform IWFileUploader that we are handling it ourselves. No need to save the file
   SaveFile := False;
   // do whatever you want here with the TStream containing the file. For instance, save to the ClientDataSet
   with ClientDataSet1 do begin
     FieldByName('FileName').AsString := FileName;
     FieldByName('FileSize').AsInteger := MS.Size;
     // set to the start of the Stream
     MS.Position := 0;
     // save to the blob field
   // Release the stream
Thanks. I had no idea those demos were even there.

Forum Jump:

Users browsing this thread: 1 Guest(s)