0
可能重複:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select無法從文件夾中下載文件
CI中我不能從一個文件夾中下載一個PDF文件。當試圖下載它, 在我們的服務器它正在工作,但在客戶端的服務器無法正常工作。可能是什麼原因?
這是我在控制器中的代碼。
$directory = './pdf/';
set_realpath($directory);
$file = $directory.'dwn.pdf';
$fp = fopen($file,'wb');
$pdfcode = "---some texts----";
fwrite($fp,$pdfcode);
fclose($fp);
$data = file_get_contents(base_url()."pdf/dwn.pdf"); // Read the file's contents
$name = 'dwn.pdf';
force_download($name, $data);
這是錯誤。
A PHP Error was encountered
Severity: Warning
Message: fopen(./pdf/dwn.pdf) [function.fopen]: failed to open stream: Permission denied
Filename: controllers/pms.php
Line Number: 732
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: controllers/pms.php
Line Number: 733
A PHP Error was encountered
Severity: Warning
Message: fclose() expects parameter 1 to be resource, boolean given
Filename: controllers/pms.php
Line Number: 734
是不是錯誤的描述解釋了什麼是錯的? – Nemoden
可能相關:http://stackoverflow.com/questions/8321275/uploading-file-issue-in-codeigniter正如在答案中告訴你的,你是否改變了你的權限? –
是的我把權限更改爲777 – Kichu