本文介紹了cakePHP 文件下載未找到或不可讀的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我已經(jīng)掙扎了一個(gè)小時(shí)試圖解決這個(gè)問(wèn)題.我用它從 app/uploads/
目錄下載文件.它說(shuō)找不到目錄或不可讀.然而我檢查了它,它也在那里使用 $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;
推薦答案
確保您沒(méi)有其他名為 File 的模型.如果是這樣 - 它顯然會(huì)覆蓋 cakephp 的核心實(shí)用程序/文件模型.
Make sure you have no other model named File. If so - it apparently overwrites the cakephp's core Utility/File model.
這篇關(guān)于cakePHP 文件下載未找到或不可讀的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!