Hi all when uploading attachments with comma and semicolon like First,Second;Last.pdf
The file is not uploaded and also the naming is corrupted to First Second Last.pdf in the attachment view leading to no file on the server.
is there a way to fix this?
Just remove the “,” and “;” character from the filename in “Row_Inserting” and/or “Row_Updating” server event by using PHP str_replace function. https://www.php.net/manual/en/function.str-replace.php
I tried this $rsnew[“InvoiceFile”] = str_replace( ‘,’, ‘’, $rsnew[“InvoiceFile”] );
The file name did change but the actual file was still not uploaded.
Are you sure? Since the filename has been successfully changed, then the updated file should be uploaded properly.
Please double check the uploaded file in the destination folder of your web application.
I did double check, maybe the file name changes after it is already trying to upload?
I thought phpmaker already should have these validations in place.
Perhaps you may write the code in “Row_Inserting” and/or “Row_Updating” server event to check/validate the filename. If it contains the invalid character such as “,” (comma) and/or “;” (semi-colon), then display the failure message and return false to prevent the upload process. This time, end-users have to make sure the filename is already valid before they uploading the files.
On Advanced Settings → Change “Multiple file upload separator” option.
- hemin wrote:
I tried this $rsnew[“InvoiceFile”] = str_replace( ‘,’, ‘’, $rsnew[“InvoiceFile”] );
You may try $rsnew[“InvoiceFile”] = str_replace([‘,’, ‘;’], [‘’, ‘’], $rsnew[“InvoiceFile”]); // Remove both comma and semicolon
- mobhar wrote:
Just remove the “,” and “;” character from the filename in “Row_Inserting” and/or “Row_Updating” server event by using PHP str_replace function
Make sure you use “Row_Inserting” and “Row_Updating”, not “Row_Inserted” and “Row_Updated”
- ucme wrote:
On Advanced Settings → Change “Multiple file upload separator” option.
This also works.
I really tried hard but non of the options you guys mentioned helped.
i did do option1, 2 and the file name is changed correctly but the file is not uploaded.
the 3rd option works but it will corrupt the old data and i do not want to do this. i also have so many tables with attachments and it is just not possible to change all the commas to something else.
mobhar wrote:
Perhaps you may write the code in “Row_Inserting” and/or “Row_Updating” server event
to check/validate the filename. If it contains the invalid character such as “,”
(comma) and/or “;” (semi-colon), then display the failure message and return false
to prevent the upload process. This time, end-users have to make sure the filename
is already valid before they uploading the files.