cakePHP File Download was not found or not readable(cakePHP 文件下载未找到或不可读)
问题描述
我已经挣扎了一个小时试图解决这个问题.我用它从 app/uploads/
目录下载文件.它说找不到目录或不可读.然而我检查了它,它也在那里使用 $file['File']['filename']
文件.我想知道我在这里遗漏了什么.?
I've been struggling now for an hour trying to fix this. I used this to download file from app/uploads/
directory. It says the directory not found or not readable. Yet i checked it and it was there also the file using $file['File']['filename']
. I want to know what I am missing here.?
$file = $this->File->findById($id);
$extension = pathinfo($file['File']['filename'],PATHINFO_EXTENSION);
$this->response->file('uploads'.DS.$file['File']['filename'], array(
'download' => true,
'id' => $file['File']['filename'],
'name' => $file['File']['filename']
));
$this->response->type($extension);
return $this->response;
推荐答案
确保您没有其他名为 File 的模型.如果是这样 - 它显然会覆盖 cakephp 的核心实用程序/文件模型.
Make sure you have no other model named File. If so - it apparently overwrites the cakephp's core Utility/File model.
这篇关于cakePHP 文件下载未找到或不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cakePHP 文件下载未找到或不可读


- 从 PHP 中的输入表单获取日期 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Laravel 仓库 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01