Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IWFileUploader using
#9
(12-17-2019, 01:59 AM)MrSpock Wrote: None of the two web addresses tell anything about methods IWFileUploader1.SelectFile IWFileUploader1.StartUpload
which must be used first, as if it was obvious.

You don't need to select the file and start the upload yourself. These methods have nothing to do with the way the files are saved in the server.

You have 2 options to deal with it:

Option 1) Implement the event OnAsyncUploadCompleted. Please check out this example and read the comments:


Code:
procedure TIWForm1.IWFileUploader1AsyncUploadCompleted(
  Sender: TObject; var DestPath, FileName: string; var SaveFile,
  Overwrite: Boolean);
begin
  // save in the user cache directory with the same name of the original file. Overwrite if it already exists.
  // Each user directory is exclusive. Files won't be overwritten by other users
  IWFileUploader1.SaveToFile(WebApplication.UserCacheDir, WebApplication.UserCacheDir + FileName, True);

  // Inform IWFileUploader that we are taking care of file saving ourselves
  SaveFile := False;
end;


Option 2) You can achieve the same thing (without coding the event), if you set IWFileUploader.AutoSavePath property when you create the form (you can only do this at runtime, not at design time):

Code:
procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
  IWFileUploader1.AutoSavePath := WebApplication.UserCacheDir;
end;

In the above case, you don't need to do anything else (no need for OnAsyncUploadCompleted event)

Just a note: UserCacheDir and everything it contains is deleted by IW application when it terminates. So, after saving the file there you might want to move it to somewhere else (if want to keep it, anyway).
Reply


Messages In This Thread
IWFileUploader using - by MrSpock - 12-16-2019, 06:50 AM
RE: IWFileUploader using - by kudzu - 12-16-2019, 02:49 PM
RE: IWFileUploader using - by MrSpock - 12-16-2019, 09:25 PM
RE: IWFileUploader using - by kudzu - 12-16-2019, 10:29 PM
RE: IWFileUploader using - by kudzu - 12-16-2019, 10:32 PM
RE: IWFileUploader using - by MrSpock - 12-17-2019, 01:59 AM
RE: IWFileUploader using - by Alexandre Machado - 12-17-2019, 09:47 PM
RE: IWFileUploader using - by kudzu - 12-17-2019, 01:53 PM
RE: IWFileUploader using - by Jose Nilton Pace - 12-17-2019, 03:00 PM
RE: IWFileUploader using - by MrSpock - 12-21-2019, 08:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)