03-15-2018, 12:10 AM
(This post was last modified: 03-15-2018, 12:10 AM by Alexandre Machado.)
Hi Dave,
Here it goes. This was extracted from one of our demos here: https://github.com/Atozed/IntraWeb/tree/...UploaderDB
Here it goes. This was extracted from one of our demos here: https://github.com/Atozed/IntraWeb/tree/...UploaderDB
Code:
procedure TIWForm51.IWFileUploader1AsyncUploadCompleted(Sender: TObject; var DestPath,
FileName: string; var SaveFile, Overwrite: Boolean);
var
MS: TMemoryStream;
begin
// Create any TStream descendant
MS := TMemoryStream.Create;
try
// 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
Append;
FieldByName('FileName').AsString := FileName;
FieldByName('FileSize').AsInteger := MS.Size;
// set to the start of the Stream
MS.Position := 0;
// save to the blob field
TBlobField(FieldByName('FileContent')).LoadFromStream(MS);
Post;
end;
finally
// Release the stream
MS.Free;
end;
end;