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 文件下载未找到或不可读
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
