2017-07-18 31 views
0

我有一個權限問題。在我的主機上我的/ home /的public_html /圖像創建的文件夾圖片,並從的cPanel 777設置完全權限當我嘗試使用懸浮窗,它說要上傳圖片:無法在public_html/images中使用laravel和intervation寫入圖片

production.ERROR: exception 'Intervention\Image\Exception\NotWritableException' with message 'Can't write image data to path (/home/username/app_folder/public/images/15003681530.jpg)' in /home/username/app_folder/vendor/intervention/image/src/Intervention/Image/Image.php:143 

爲什麼試圖寫入/ home/username/public/images文件夾?該文件夾是不是在這條道路,是在/ home /用戶名/的public_html /圖像

// create a unique name for each image 
$filename = time() . $i . '.' . $image->getClientOriginalExtension(); 
// create a location 
$location = public_path('images/').$filename; 
// save the image to that location 
Image::make($image->getRealPath())->resize(200,200)->save($location); 

我使用laravel 5.4和干預形象的laravel。

+0

如果我將$ location而不是public_path('images')設置爲'/ home/username/public_html/images'作品。什麼函數用於獲取公用文件夾位置? – calin24

回答

0

我發現這個方法:

$location = base_path().DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public_html/images/'.$filename; 

我心底有這樣的每一次改變,當我上載我的項目了。在本地主機上的公共文件夾是在項目中,當我在我的域名上傳項目時,我將公共項目分開。公用文件夾的內容位於public_html文件夾中,並且項目本身位於根主文件夾