2017-10-13 17 views
-3

我用下面的代碼的其他網址的圖像保存到我的文件夾file_put_contents(d: XAMPP htdocs中 TOH條碼 PUBLIC 上傳條形碼):未能打開流:權限被拒絕

<?php 
    $string = "https://eandata.com/.../products/000/000/0000000000000.jpg"; 
    $img = public_path('uploads\barcode'); 
    file_put_contents($img, file_get_contents($string)); 
? 

它報告錯誤:「file_put_contents(D:\ xampp \ htdocs \ toh-barcode \ public \ uploads \ barcode):無法打開流:拒絕權限。」 如何修復錯誤。感謝所有

+0

錯誤解釋本身。爲該文件設置寫入權限。 – urfusion

+0

您的網絡服務器是否有權寫入該文件夾? – Jerodev

+0

如何設置目錄的權限? –

回答

0

我的解決辦法是將文件夾給了圖像文件夾的權限>右鍵點擊>屬性和進入權限,然後改變所有的權限讀取&寫

0

首先請換上傳/條碼取代上傳\條碼 然後請確保路徑上傳/條碼已創建。

$path = 'uploads/barcode'; 
if (!file_exists($path)) { 
    mkdir('uploads/barcode'); 
} 

如果還是不行,請改變foder的權限讀取&寫:

Linux或Mac OS

chmod -R 777 

WINDOWNS

Going to the Folder > Right click > properties and goes to Permission and then change all the permissions to Read & Write 
相關問題