链接到CakePHP视图中的文件(例如PDF) [英] Linking to a file (e.g. PDF) within a CakePHP view
问题描述
我想在我的控制器视图中链接到一些PDF。什么是完成这个的最佳实践? CakePHP webroot文件夹包含一个./files/子文件夹,我被困惑,试图链接到它,而不使用魔术路径名在我的href(例如/path/to/my/webroot/files/myfile.pdf)。
我的选项是什么?
EDIT:我的问题。我试图链接到/ app / webroot / files /中的平台无关的(即 mod_rewrite
)方式的文件。
我以前通过将这些文件存储在CakePHP目录结构之外来解决这个问题。
p> $ html-> link('Pdf','/files/myfile.pdf');
I'd like to link to some PDFs in one of my controller views. What's the best practice for accomplishing this? The CakePHP webroot folder contains a ./files/ subfolder, I am confounded by trying to link to it without using "magic" pathnames in my href (e.g. "/path/to/my/webroot/files/myfile.pdf").
What are my options?
EDIT: I didn't adequately describe my question. I was attempting to link to files in /app/webroot/files/ in a platform-agnostic (ie. no mod_rewrite
) way.
I've since worked around this issue by storing such files outside the CakePHP directory structure.
$html->link('Pdf', '/files/myfile.pdf');
这篇关于链接到CakePHP视图中的文件(例如PDF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!