2013-11-27 156 views
-3

我得到否認權限,當我使用fopen在WAMP服務器的文件夾在Windows上:權限被拒絕上的fopen

# open file to write 
$fp = fopen ($path, 'w+'); 

# start curl 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 

# set return transfer to false 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

# increase timeout to download big file 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 

# write data to local file 
curl_setopt($ch, CURLOPT_FILE, $fp); 

# execute curl 
curl_exec($ch); 

# close curl 
curl_close($ch); 

# close local file 
fclose($fp); 
+0

歡迎堆棧溢出。請閱讀常見問題解答,瞭解如何正確設置問題的格式,以便獲得社區的最佳答覆。 http://stackoverflow.com/help – webnoob

+0

請提供適當的細節,並以適合其他人理解的格式提出您的問題。 – Akshat

+0

你試過或死()來得到錯誤? – Lefsler

回答

2

請嘗試這樣的,我對WAMP檢查,希望這應該爲你工作。

創建文件DiwanOnline文件夾,並使用這樣的..

$path = $_SERVER['DOCUMENT_ROOT']."\\DiwanOnline\\testfile.txt"; 
# open file to write 
$fh = fopen($path,'w'); 
$URL="http://stackoverflow.com/questions/20240205/i-have-a-permission-denied-proplem-when-i-excecute-php-fopen-to-the-folder-in-wa#20240205"; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE); 
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_URL, $URL); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 120); 
curl_setopt ($ch, CURLOPT_FILE, $fh); 
curl_exec ($ch); 
curl_close ($ch); 
fclose($fh); 

警告:的fopen(C:/瓦帕/網絡/ DiwanOnline) [function.fopen]:未能打開流:第59行中的C:\ wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine.php中的權限被拒絕。警告:curl_setopt():提供的參數不是C:\ wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine中的有效文件句柄資源。第72行警告:fclose():提供的參數不是C:\ wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine.php中的有效流資源,位於75行

啊......你試圖打開文件夾,而不是文件

請修復它

+0

尚未批准@Siraj Khan –

+0

您能不能請我們分享確切的錯誤信息,以便我們整理出問題 –

+0

警告:fopen(C:/ wamp/www/DiwanOnline)[功能。 fopen]:未能打開流:權限在C:\ wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine.php中被拒絕59行 警告:curl_setopt():提供的參數不是C:\中的有效文件句柄資源wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine.php on line 72 Warning:fclose():suppl ied參數不是在線75中的C:\ wamp \ www \ DiwanOnline \ Diwan \ downLoadDiwanOnLine.php中的有效流資源@ Siraj Khan –