我问过一个关于文件上传的问题。我设法使其正常工作,下一步是让客户下载文件,文件的格式可能从视频到PDF都不同。
我确实读过有关媒体观点的文章,但它们在cakephp 2.0中。我发现2.0似乎至少对我造成了问题。
如果有帮助,我可以上传文件进行上传。
亚历克斯(Alex)发布的链接上的内容,在我看来,我将如何调用此函数,这是来自cakephp书本链接的函数
public function downloadFile($id)
{
$file = $this->Attachments->getFile($id);
// a view.
$this->response->file(
$file['files/content'],
['download' => true]
);
return $this->response;
}
要获得到该功能的链接(使用cakephp默认路由),您可以在视图中执行以下操作:
echo $this->Html->link('Download File', ['controller' => 'Attachments', 'action' => 'download_file', $id]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句