[quote="GreyHead"]Hi angelmorales,
Sorry, you are right. The DownLoad files action only works for a fixed file name and path.
I got this code to work in Chrome - it downloads the renamed file.
<?php
$file_path = $form->files['cf_pdf_file']['path'];
if ( file_exists($file_path) ) {
\GCore\Libs\Download::send($file_path);
}
?>
Note that cf_pdf_file may need to be changed if that is set differently in the TCPDF action.
Bob[/quote]
Thats the code that I use but it doesnt work.
In TCPDF, in the Option "VIEW" I put: Save+Display inline ,
In the "SAVE PATH" option I put the save path
In the "FILE NAME IN DATE" option, no change (Image1)
After TCPDF I put a Custome Code with the following code:
<?php
jimport('joomla.filesystem.file');
// copy the entry from the 'File name in Data/Files array' setting
$data_file_name = 'cf_pdf_file';
$name = $form->files[$data_file_name]['name'];
$path = $form->files[$data_file_name]['path'];
// remove the file name from the full path
$path = str_replace($name, '', $path);
if ( !JFile::exists($path.$name) ) {
echo 'File not found';
return false;
}
$ext = JFile::getExt($path.$name);
// create a new name here - can use $form->data
$new_name = $form->data['ID_Tienda'].date('YmdH');
$new_name .= '.'.$ext;
// rename the file
$test = JFile::move($path.$name, $path.$new_name);
// update the $form->files values
$form->files[$data_file_name]['name'] = $new_name;
$form->files[$data_file_name]['path'] = $path.$new_name;
// fix URL bug
$url = str_replace(JPATH_SITE.'/', JURI::root(), $path);
$form->files[$data_file_name]['link'] = $url.$new_name;
$form->debug[] = print_r($form->files, true);
?>
In the end I put another Custome Code with the code that you share to me:
[code]<?php
$file_path = $form->files['cf_pdf_file']['path'];
if ( file_exists($file_path) ) {
\GCore\Libs\Download::send($file_path);
}
?>[/code]
(Image2)
When I submit the form the PDF shows Inline in my chrome explorer,thats correct, because I can download the pdf from Chrome explorer , when I check the SAVE PATH the PDF its saved too, at this point everything its fine.
The problem its that the name of the file that its saved in the SAVE PATH hasnt been renamed with the data that I declare in the Custome Code:
$new_name = $form->data['ID_Tienda'].date('YmdH');
, it keeps saving with the forms name (Image3)
Thanks for your attention