Page 1 of 1

cannot reset upload file file name

Posted: Tue May 07, 2019 4:37 am
by kleung
Hi,

I have defined an input file in dynaform for file upload. In order to allow users re-upload the file when they clicked on wrong files, I set an iteration to the task. When the task is re-iterated, the filename and filename_label of the upload file variable are set to "". I could allow user to re-upload their files. However, I cannot clear the old file name of the previous selected file appeared in the file selection field.

Grateful if I can be advised how to clear the field value.

I'm using Bitnami 3.2.1 on Linux version.

Many Thx

cheers,
Karl

Re: cannot reset upload file file name

Posted: Tue May 07, 2019 10:05 pm
by amosbatto
Is there any reason why you can't use a MultipleFile field? It allows your users to delete the files.

Deleting files from File fields is complicated. You have to change the database record. I can write up a solution if absolutely necessary, but why can't you use a MultipleFile field? If you only want the user to upload 1 file, see:
https://www.pmusers.com/index.php/Limit ... aded_files

Re: cannot reset upload file file name

Posted: Thu May 09, 2019 12:44 am
by kleung
Hi Amos,

Thank you for your advice. Your approach serve the functional purpose.
Since I allow users upload only ONE file. Users can be confused that they are allowed to upload more than one files but error message popped up.
Can the button of file uploading be locked or hide as well as changing the label of the button after users have uploaded the maximum amount of files?

Alternatively, a solution with Single File upload would be required.

which approach would be simpler?

thousand thanks

cheers,
Karl

Re: cannot reset upload file file name

Posted: Thu May 09, 2019 9:14 pm
by amosbatto
kleung wrote:Since I allow users upload only ONE file. Users can be confused that they are allowed to upload more than one files but error message popped up.
Can the button of file uploading be locked or hide as well as changing the label of the button after users have uploaded the maximum amount of files?
Karl, I added an example of how to hide the button to upload more files:
https://www.pmusers.com/index.php/Limit ... ect_number

The File field has so many limitations, that I can't recommend using it.

Re: cannot reset upload file file name

Posted: Thu May 16, 2019 4:20 am
by kleung
Hi Amos,

thanks for your code. The "File Upload" button was hide after the number of files reach the upload limit.

However the "Submit" button followed is disabled and hence the form could not be submitted.
Please advise how to fix it.

Many Thanks.

cheers,
Karl

Re: cannot reset upload file file name

Posted: Thu May 16, 2019 9:08 pm
by amosbatto
Karl, I don't see that problem when I run a case. Here is my Dynaform for you to test:

Re: cannot reset upload file file name

Posted: Mon May 20, 2019 3:15 am
by kleung
Hi Amos,

I used your code and works now.

By the way, I could get the ID and filename with the code
if (isset(@=multipleContractFiles) and !empty(@=multipleContractFiles)) {
@@firstFileId = @=multipleContractFiles[0]['appDocUid'];
@@firstFilename = @=multipleContractFiles[0]['name'];
}
from https://wiki.processmaker.com/3.2/Multi ... e_Uploader.
But I could not find the Path field in the APP_DOCUMENT table.
My files are Excel files.
How can I get the paths of the files uploaded such that I can pass them to PhpSpreadsheet to load the contents into a grid?

Thousand Thanks again.

cheers,
Karl

Re: cannot reset upload file file name

Posted: Tue May 21, 2019 12:57 am
by amosbatto
You can get the file's path on the ProcessMaker server like this in a trigger:
Code: Select all
@@firstFileId = @=multipleContractFiles[0]['appDocUid'];
@@firstFilename = @=multipleContractFiles[0]['name'];
$firstVersion = @=multipleContractFiles[0]['version'];

//construct path to the stored file in the server's file system:
$ext = pathinfo(@@firstFilename, PATHINFO_EXTENSION);
$g = new G();
$path = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP .
         @@firstFileId . '_' .  $firstVersion . '.' . $ext;

Re: cannot reset upload file file name

Posted: Tue May 21, 2019 2:28 am
by kleung
Hi Amos,

It works.

Thousand Thanks

cheers,
Karl