CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Execute Upload Files on runtime

by feland » 07 Jan 2016 17:39

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
feland
 
Posts: 89
Joined: 15 Jun 2015 15:12

by Jorge Sousa » 07 Jan 2016 18:47

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?
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by feland » 08 Jan 2016 09:16

This code is on event
Code: Select all
btnVisualizzaFattureIdricoJQButtonOptionsClick(Sender: TObject; AParams: TStringList);
feland
 
Posts: 89
Joined: 15 Jun 2015 15:12

by Alexander Bulei » 11 Jan 2016 11:58

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.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by feland » 11 Jan 2016 12:38

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
feland
 
Posts: 89
Joined: 15 Jun 2015 15:12

by Jorge Sousa » 11 Jan 2016 12:54

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;
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by feland » 11 Jan 2016 15:03

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??
feland
 
Posts: 89
Joined: 15 Jun 2015 15:12

by Alexander Bulei » 11 Jan 2016 16:17

Hi feland,

C:\work\pippo.pdf


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

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by feland » 11 Jan 2016 16:47

is on client side
feland
 
Posts: 89
Joined: 15 Jun 2015 15:12

by assapan » 11 Jan 2016 17:04

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 ?
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

Next

Return to JQFileUpload

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.