CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

OnSaveFile

by etwoss » 23 Apr 2017 06:29

Hi

This event is added on request to stop uploading a file if , for some reason, you don't want to uplod is, for example if it already exists.

However the param "ATempPathName" hold a value like "'C:\Users\ADMINI~1\AppData\Local\Temp\01b8pv0gwr\ATZ35DF5FB18825.tmp" where the filename is "Boost.txt" and if i set the param "AHandled" to true of false, the file is still in UploadOptionsComplete event.

Added 24-2-2017:
Just checked the sourcecode:
Code: Select all
    LIsHanlded:= False;
    if Assigned(FOnSaveFile) then
      FOnSaveFile(Self,LFile.TempPathName,LIsHanlded);



So the "LFile.TempPathName" is what i get, where i need "Filename"
if AHandled = True, the file is not saved, which i tested and works fine

However i don't expect the file be present in the list of uploaded files in the UploadOptionsComplete event.

Also the file is made visible ( A set Handled to true for B4.png) so i don't expect that one to show up.



Eric
You do not have the required permissions to view the files attached to this post.
Last edited by etwoss on 24 Apr 2017 07:58, edited 2 times in total.
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by etwoss » 24 Apr 2017 07:45

Hi

Second question

In the event, i check if the file already exists, if so i need to ask the User if he wants to overwrite the file, if no, the file should not get uploaded.
However showing a confirmation dialog is not the correct way because the OnSave event had ended already before the dialog is shown.

How to handle this situation?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Alexander Bulei » 26 Apr 2017 15:50

Hi Eric,

So the "LFile.TempPathName" is what i get, where i need "Filename"
if AHandled = True, the file is not saved, which i tested and works fine


I have added new event OnSaveEx..available in next beta build(s).

However i don't expect the file be present in the list of uploaded files in the UploadOptionsComplete event.

Also the file is made visible ( A set Handled to true for B4.png) so i don't expect that one to show up.


Use the Exception to avoid this behavior.

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 etwoss » 27 Apr 2017 06:42

Hi

Installed 218

Should the SaveEx be there?

What do you mean , use an exception?
Hrow an exception as the users answers no in the confirmation dialog?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Alexander Bulei » 02 May 2017 09:37

Hi Eric,

Installed 218

Should the SaveEx be there?


This event is available since 3.0.0.219
What do you mean , use an exception?


delphi code
raise Exception.Create('File already exists!');


Hrow an exception as the users answers no in the confirmation dialog?


I will check if it possible.

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 etwoss » 12 Jul 2017 09:52

Hi

Never had an answer

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by etwoss » 04 Sep 2017 10:28

Hi

Still no answer?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 06 Sep 2017 15:05

Hi Eric

This is a good a idea, but unfortunatelly,
You can't use the OnFileSave, OnFileSaveEx, OnGetFileName to perform any visual changes including a verification message.

Currently the only is if you check if the file exists in OnGetFileName, if it exists set a flag, give it an temp unique name, and in JQUploadOptions.OnComplete, if exists then you can ask the user so that you can delete and rename the temp file if user says yes, or just delete the temp file if it says no.

Of course that a file will be download whether wants to overwrite it or not :/
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 06 Sep 2017 15:28

Hi

Good solution

Thanks

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58


Return to JQFileUpload

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.