Category: Views
Hi Aero Coding:
I have a project written in CakePHP 2 that provides pdf storage and sharing service to end users. The pdf name of download links are same as is the hash name in s3, and pdf file name was generated form objectId-like unique ID, for example,
files/ca8W7mc0ZUx43bxTuSGN.pdf
Recently the client wants to use "readable" file names like
Evans_Ebook.pdf
instead of non-readable objectIds. The original file name was saved in DB that can be retrieved by objectId.
* download.ctp:
<?php echo $this->Html->link('Download PDF Now', $f['File']['url'], array(
'class' => 'btn btn-primary btn-xs',
'rel' => 'nofollow'
)); ?>
* data
$f['File']['url']; // s3 URL
$f['File']['name']; // original file name
$f['File']['owner']; // owner ID..etc
Thanks
SOLVED aws s3 pdfVersion: 2.2
Add download attribute to <a> tag should work in your case : )
<?php echo $this->Html->link('Download PDF Now', $f['File']['url'], array(
'class' => 'btn btn-primary btn-xs',
'rel' => 'nofollow',
'download' => $f['File']['name']
)); ?>
HTML 4.01 & HTML 5 HTML <a> download Attribute
<a download="filename">
Created: 3 Oct '16
Last Reply: 3 Oct '16
Replies: 1
Views: 5286
Votes: 0