Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWFileUploader OnAsyncUploadCompleted question
#2
Hi Dave,

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;
Reply


Messages In This Thread
RE: TIWFileUploader OnAsyncUploadCompleted question - by Alexandre Machado - 03-15-2018, 12:10 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)