我已经挣扎了一个小时试图解决这个问题.我用它从 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 文件下载未找到或不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
不能使用 'Object 作为类名,因为它是保留的Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作为类名,因为它是保留的 Cake 2.2.x)
OAuth 重定向后会话丢失Session is lost after an OAuth redirect(OAuth 重定向后会话丢失)
Cakephp 3.x 中的分页排序Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分页排序)
CakePHP 多个应用程序的共享核心CakePHP Shared core for multiple apps(CakePHP 多个应用程序的共享核心)
在 CakePHP 3 上登录 [ Auth->identify() ] 始终为 falLogin [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登录 [ Auth-identify() ] 始终为 false)
致命错误:允许的内存大小为 134217728 字节已用尽Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命错误:允许的内存大小为 134217728 字节已用尽