Laravel Wont写信给目录

时间:2014-09-10 02:53:47

标签: php laravel

Laravel不会写到我的目录。

我得到的错误是。

ErrorException

Unable to write in the "/var/www/laravel/laravel/public/img/retailer_images/12/" directory (View: /var/www/laravel/laravel/app/views/edit_retailer.blade.php)

文件" img"是由ubuntu:www-data和拥有0777的权限。

我确信我错过了一些简单的事情。

输入代码是,(我知道这可以在其他已部署的服务器上运行)

    if  (file_exists    ('/img/retailer_images/$retailer_id/banner.png')    )   {
            unlink('/img/product_images/$retailer_id/banner.png');          
        }
        $file                = Input::file('image');
        $extension = Input::file('image')->getClientOriginalExtension();
        if($extension=="jpg" || $extension=="jpeg" )
            {
            $src = imagecreatefromjpeg($file);
            }
        else if($extension=="png")
            {
            $src = imagecreatefrompng($file);
            }
        else 
            {
            $src = imagecreatefromgif($file);
            }
        list($width,$height) = getimagesize($file);
        $tmp                 = imagecreatetruecolor("600","162");
        $force_resize        = imagecopyresampled($tmp,$src,0,0,0,0,"600","162", $width, $height);
        $destinationPath     = public_path().'/img/retailer_images/'.$retailer_id.'/';
        $filename            = "banner.png";
        $uploadSuccess       = $file->move($destinationPath, $filename);
        $new_file_dest       = $destinationPath.$filename;
        DB::table('retailers')->where('id', $retailer_id)->update(array('retailer_img_url' => "http://sniip-kinetic-env-dqcu3vmfku.elasticbeanstalk.com/img/retailer_images/$retailer_id/banner.png"));
// TO DO add user friendly message here displayed with the image they just uploaded in a thumb size (300 X 300)     
        echo "<img src=/img/retailer_images/$retailer_id/banner.png height=162 width=600> </img><br />";
        echo "file uploaded";
    } 

2 个答案:

答案 0 :(得分:1)

抱歉,没有足够的代表发表评论:

你的app / storage / logs / laravel.log有什么用?以及/ var / logs / -webservername- / error_log?

还要确保您的Apache / nginx在www-data下运行 ..

另一件事:

尝试

('/img/retailer_images/$retailer_id/banner.png')  
带双引号的

并且像这样:

("/img/retailer_images/{$retailer_id}/banner.png") 

答案 1 :(得分:0)

这是一个真正模糊的问题,问题是文件中存在损坏的数据.... / img / 12 / named banner.png无法覆盖(Pems问题)我将其从git存储库中删除推了推,然后拉到遥控器。然后我按下好的'OL F5,这一切都很完美,谢谢你的帮助。