Page 1 of 2

Execute Upload Files on runtime

PostPosted: 07 Jan 2016 17:39
by feland
Hi, I create a JQFileUpload component on runtime but i 'don't understand how trigger the upload event.
I would like to upload my files in the folder "pdf" and view this on new window. When I execute the instruction "FileUpload.FileNames.Add" the path into the array aIDFattureIdricoShow[i] is "C:\Users\Developer\Desktop\Pdf_Fattura_Idrico\prova.pdf"

Following the code that I used:
Code: Select all
FileUpload:=TIWCGJQFileUpload.Create(nil);
      FileUpload.JQFileUploadOptions.AutoUpload:=true;
      FileUpload.JQFileUploadOptions.Multiple:=false;
      FileUpload.JQFileUploadOptions.ShowUploadedFileList:=false;
      FileUpload.JQFileUploadOptions.UploadPath:= WebApplication.ApplicationURL + '/pdf/';
      FileUpload.FileNames.Clear;
      if trim(aIDFattureIdricoShow[i]) <> '' then
      begin
        FileUpload.FileNames.Add(aIDFattureIdricoShow[i]);
        WebApplication.NewWindow(CGGetLink(WebApplication.ApplicationURL + '/pdf/' ,FileUpload.FileNames.Names[0],False,False));
      end;


Can You help me?
Thanks,

feland

Re: Execute Upload Files on runtime

PostPosted: 07 Jan 2016 18:47
by Jorge Sousa
hello

about

create a JQFileUpload component on runtime


First of all, where do you have this code? in an ajax event or on create / full post event?

Re: Execute Upload Files on runtime

PostPosted: 08 Jan 2016 09:16
by feland
This code is on event
Code: Select all
btnVisualizzaFattureIdricoJQButtonOptionsClick(Sender: TObject; AParams: TStringList);

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 11:58
by Alexander Bulei
Hi feland,

Can you explain better what are you trying to do (the workflow), because I don't understand, for what you need fileUpload component, which is needed only when required the file(s) from client.

Question: For what you need the FileUpload on server side?

Best Regards.

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 12:38
by feland
Hi,
I need to load the file from client to a server and after load it I use the file on server for display it into a new browser window.
My final target is view the file (*.pdf) into a new window.
Thanks

feland

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 12:54
by Jorge Sousa
Hello

First of all, you cannot do what you want, it is forbidden. The browser user, have to do the upload manually.

Then you can trap the upload event FileUpload.JQFileUploadOptions.OnComplete, and use the FileUpload.FileNames to get the path and name.

About

btnVisualizzaFattureIdricoJQButtonOptionsClick(Sender: TObject; AParams: TStringList);


if btnVisualizzaFattureIdricoJQButtonOptions.Ajax=True (defaullt value), you would have to code something like:

uses
IWCGJQCommon;

CGCallbackDisableAjaxResponse;
try
FileUpload:=TIWCGJQFileUpload.Create(Self); // NOT nil
FileUpload.Name:= 'somename'; // MUST HAVE A NAME
FileUpload.Parent:= Self; // AND A PARENT
FileUpload.JQFileUploadOptions.AutoUpload:=true;
FileUpload.JQFileUploadOptions.Multiple:=false;
FileUpload.JQFileUploadOptions.ShowUploadedFileList:=false;
FileUpload.JQFileUploadOptions.UploadPath:= WebApplication.ApplicationURL + '/pdf/';
finally
CGCallbackEnableAjaxResponse;
end;
FileUpload.AjaxReRender;

Just to show the FileUpload

All of the rest doesn't make sense either:

// FileUpload.FileNames.Clear; // THIS MUST BE USED READONLY
// if trim(aIDFattureIdricoShow[i]) <> '' then
// begin
// FileUpload.FileNames.Add(aIDFattureIdricoShow[i]);
// WebApplication.NewWindow(CGGetLink(WebApplication.ApplicationURL + '/pdf/' ,FileUpload.FileNames.Names[0],False,False));
// end;

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 15:03
by feland
But in my case the user cannot select the file to upload.
The user don't view the screen that permits him to select the file.
The file is selected by the program and dinamically inserted into the component Fileupload with this instruction
Code: Select all
FileUpload.FileNames.Add('C:\work\pippo.pdf');


My question is :
How can I upload the file "C:\work\pippo.pdf" into the folder FileUpload.JQFileUploadOptions.UploadPath without show any screen??

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 16:17
by Alexander Bulei
Hi feland,

C:\work\pippo.pdf


And this file/path in on server or client side?

Best Regards.

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 16:47
by feland
is on client side

Re: Execute Upload Files on runtime

PostPosted: 11 Jan 2016 17:04
by assapan
Sorry to interfere in your conversation :mrgreen:

How does the pippo.pdf comes to the client side ?
do you have a subprogram running on the client machine which create this file ?