File Upload - Rename

HyperOsmar

Member
Dear friends,

Following the guidelines I found on the forum, I put the following code in the element FileUpload (file_upload):

$nome = $formModel->getElementData('cad_modelo_cadastro___fullname_raw');
$cpf = $formModel->getElementData('cad_modelo_cadastro___username_raw');
ext = JFile::getExt($filename);​

$filename = $nome."-".$cpf.".".$ext;
return $filename;​



The file is saved correctly as desired, but the following error message appears (file_upload2):

"An error occurred with the rating field - please inform the site administrator.
Debug: Eval exception : arquivos::renameFile() : OSMAR DE ARAUJO-41101780230.pdf : Undefined property: stdClass::$cad_modelo_cadastro___id_raw"​

Can anyone help me understand this error???...


Tks...
 

Attachments

  • file_upload.png
    file_upload.png
    34.4 KB · Views: 69
  • file_upload2.png
    file_upload2.png
    12.9 KB · Views: 69
@troester,
I use version 3.9.2.
But the problem was solved just by updating the fileupload.php as suggested by GitHub.
Again, thanks a lot for the help...

...
 
Dear friends,...

I thought I solved the problem.

I made the fileupload.php update suggested in the GitHub.

Without updating the fileupload.php the file is loaded normally but the error message mentioned in the first topic appears.

With the update of fileupload.php the message disappears, but the upload occurs normally, the file is renamed correctly, the file appears to be saved inside the destination directory, but when opening the form to edit it or just view it, the file does not appear..

Detail: the code to rename the file only works with the "Use Ajax upload" option turned off.

What am I doing wrong???...

In Fabrik's general settings, can I select "No" in the fabrikDebug field???...
 
Last edited:
Dear friends,...

In short: after several tests I realized that, regardless of whether the fileupload.php file is updated or not, the registration form works perfectly using the code proposed above and with the option "Use Ajax upload" disabled.

The user is able to register (new) and the file is automatically renamed. The file is saved in the Media folder. The address of the file appears in the database column.

When editing the registry, the file reference simply disappears from the database, but the file is still saved in the Media folder.

Is there any way the fileupload element is not editable???...
 
As the 'Rename Code' tooltip says
OPTIONAL - PHP code to rename the uploaded file. Original filename is in $filename. Data is in $formModel->formData, but will NOT be there if AJAX uploading. MUST return a valid name, with the same extension as the uploaded file. Do not prepend folder names, just return a simple foo.ext name.
For element not editable: did you try element access settings form(add/edit)?
 
@troester, i'm sorry, but i don't quite understand...

It would be as shown in the picture file_upload_003???...
 

Attachments

  • file_upload_003.png
    file_upload_003.png
    28.5 KB · Views: 66
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top