Forums

How to configure File download in Table view CCv6

Elita- 15 Mar, 2018
Hello to all!

I have a nicely set up Table with the uploaded filename view. I wanted to create file download link to download each listed file but did not suceed.
Steps I have done so far:
1. Create file download function download_photo:
a) with the direct link to folder on server where the file is located, e.g. /var/www/vhosts/domain.com/images/uploads/FOTO/ in
File or directory path field instead of built-in {path:root};
b) leave all other fields as default;
2. Create photo_download_link wiew Link with Content {var:submissions_list.row.Submission.spFoto} where submissions_list is Read Data function and Submission.spFoto is Model.Field; URL and/or URL parameters aid={var:submissions_list.row.Submission.aid}; Event photo_download
3. Create Event photo_download with the function call: {fn:download_photo} ;
4. And finally, add the view to the Table - Columns views - Submission.spFoto: {view:photo_download_link}

So - filename is visible in the Table, link has been created. By pressing that link, download function has being executed; only problem is that it downloads FOTO instead of file.
My suspicion is that I have to somehow include the filename in that path - tried {var:submissions_list.row.Submission.spFoto} and {data:Submission.spFoto} with no sucess.
Any suggestions?
BTW - if I choose Auto selection option "Last modified" - i get file download, but as expected - only the last modified file, not the file for each Submission in the list.

Any sugestions?
Elita
Elita- 15 Mar, 2018
The same problem is when I create Photo view with php function:

I have created php function for the photo view with the view Event (thanks to earlier Forum posts) :

$path='/var/www/vhosts/domain.com/images/uploads2018/FOTO';
$file= $row['Submission']['spFoto'];
echo "<img src='{$path}{$file}' />";

when opening the Submission with the view event I got broken image link thumbnail - it points to folder, not the file:
<img src="/var/www/vhosts/domain.com/images/uploads2018/FOTO">

what would be the solution here? Thank you in advance.

Elita
Max_admin 18 Mar, 2018
Hi Elita,

To view the file in the browser you need to use the web url, but you are using the absolute server url, example:
http://www.domain.com/images/uploads2018/FOTO/

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Elita- 18 Mar, 2018
Of corse!😀 Tahnk you, Max. However, I still cannot get the filename in that path - most certainly the code for retrieving that is wrong.
Could you correct that?
$path='http://www.mydomain.com/images/uploads2018/FOTO/';
$file= $row['Submission']['spFoto'];
echo "<img src='{$path}{$file}' />";
where Submission is Model and spFoto is the DB field where filename is recorded.
Elita- 18 Mar, 2018
And how to configure the file download path for file dowload function?
Max_admin 18 Mar, 2018
Hi Elita,

The Download function requires the server path, which is the one you are using before.

For the code, where do you call this code ? if its in a PHP function then is the $row var defined ? I think that you can just use an HTML view instead:
<img src="http://www.mydomain.com/images/uploads2018/FOTO/{var:table_name.row.Model.field_name}" />
Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Elita- 18 Mar, 2018
Max, for the file download i wrote before in my first message:

I have a nicely set up Table with the uploaded filename view. I wanted to create file download link to download each listed file but did not suceed.
Steps I have done so far:
1. Create file download function download_photo:
a) with the direct link to folder on server where the file is located, e.g. /var/www/vhosts/domain.com/images/uploads/FOTO/ in  File or directory path field instead of built-in {path:root};
b) leave all other fields as default;
2. Create photo_download_link wiew Link with Content {var:submissions_list.row.Submission.spFoto} where submissions_list is Read Datafunction and Submission.spFoto is Model.Field; URL and/or URL parameters aid={var:submissions_list.row.Submission.aid}Eventphoto_download
3. Create Event photo_download with the function call: {fn:download_photo} ;
4. And finally, add the view to the Table - Columns views - Submission.spFoto: {view:photo_download_link}

So - filename is visible in the Table, link has been created. By pressing that link, download function has being executed; only problem is that it downloads FOTO instead of file.
My suspicion is that I have to somehow include the filename in that path - tried {var:submissions_list.row.Submission.spFoto} and {data:Submission.spFoto} with no sucess.
Any suggestions?
BTW - if I choose Auto selection option "Last modified" - i get file download, but as expected - only the last modified file, not the file for each Submission in the list.
Elita- 18 Mar, 2018
Answer
1 Likes
The code you provided, Max, did not wok for me.
This code works -
<img src="http://www.mydomain.com/images/uploads2018/FOTO/{var:read_data.Model.field_name}" />
where read_data is Read Data function that reads single record.
This topic is locked and no more replies can be posted.