Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IW15-Incorrect filelist in IWFileUploader
#1
Hi,
I'm using Delphi 10.2 update 3, and recently installed version 15.1.0  of IW. I also use last version of TMS Intraweb controls.
In an application I have a IWFileUploader control, with default values in properties (unless the name, of course).
When I run my application, I drag an drop several files (they appears as "uploaded"), and after the user performs some operations, I will try to copy to another location, using this code:

if CargarFicheros.FileList.Count > 0 then
  begin
    for I := 1 to CargarFicheros.FileList.Count do
    begin
      FormaNombreFicheroDestino(I, FicheroDestino);
      CargarFicheros.SaveToFile(CargarFicheros.FileList[I - 1].FileName, FicheroDestino, True);
    end;
  end;


FormaNombreFicheroDestino is:

FicheroDestino := RutaFicheros_Presupuestos + 'P' +
                      Serie_Presupuestos + '_' +
                      CabPresupuestoCliente.cpr_nro.ToString + '#' +
                      I.ToString + '_' +
                      CargarFicheros.FileList[I - 1].FileName;



I have 2 problems:
a) FileList has only one element, regardless the number of files I've uploaded
b) When I refer to FileList [0].FileName, I get an Access Violation (whilst the element 0 of the list is not nil)

Could you please help me with this error?

Best regards,

                  Venancio Lasquibar

Could you
Reply
#2
Hi,

Has anybody an idea about this problem?

Best regards,
Venancio Lasquibar
Reply
#3
I'll try it out and let you know ASAP
Reply
#4
After reading your report, seems that the problem is in your code.

The file list only contains the files being uploaded *during* specific IWFileUploader events. More specifically during OnAsyncUploadCompleted event.

When the upload is done, i.e. the file is saved to your HDD, the file list is cleared (at an undetermined time) and you can't rely on it anymore. IWFileUploader doesn't keep track of saved files once they are saved to the disk.

If you want them saved to a different place you have 2 options:

- Save them to that place upfront
- Keep track of the saved files in a list and then move them at some point when required.
Reply
#5
BTW, when IWFileUploader saves the files, they go to:

IWFileUploader.AutoSavePath (if set. Please notice that when this is set, there is a single folder for all user sessions)

or

WebApplication.UserCacheDir folder (each user has an exclusive folder, so they won't mix)
Reply
#6
Hi Alexandre,

I'll change my code according your advice and I'll come back with the result.
Thank you.

Best regards,

Venancio Lasquíbar
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)