我现在已经努力解决这个问题一个小时了。我用它从 app/uploads/
目录下载文件。它说目录未找到或不可读。但我检查了一下,发现里面也有使用 $file['File']['filename']
的文件。我想知道我在这里缺少什么。?
$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 的核心实用程序/文件模型。
关于php - cakePHP 文件下载未找到或不可读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18222047/