2017-06-15 53 views
1

我在Laravel的文章版本级别上有一个问题。文章的照片版本无法正常工作。图片源不可读Laravel 5.3

我有以下错误:image source not readable

我在Laravel新的,但我喜欢这样做,如果一个图像编辑时已经存在,他一直起源:)

的照片我的cotroller:

public function update(Request $request, $id){ 
    $article = Article::find($id); 
    $categorie = Categorie::find($article->idcategorie); 
    if($article == null) 
     return redirect("/home"); 
    $validation=[]; 
    $langues=Langue::all(); 
    foreach ($langues as $key => $value) { 
     $validation["titrel".$value->id]='max:255'; 
    } 
    $this->validate($request, $validation); 
    DB::beginTransaction(); 
     try{ 
     $file=$request->file('upload'); 
     $path=storage_path('app/public/'.$categorie->libelle); 
     if(!Filemgr::exists($path)) { 
      Filemgr::makeDirectory($path.'/mini', 0766, true); 
      Filemgr::makeDirectory($path.'/micro', 0766, true); 
     }    
     Image::make($file) 
      ->resize(1400, null, function ($constraint) { 
       $constraint->aspectRatio(); 
      }) 
      ->save($path.'/'.$article->url); 
     Image::make($file) 
      ->resize(900, null, function ($constraint) { 
      $constraint->aspectRatio(); 
      }) 
      ->save($path.'/mini/'.$article->url); 
     Image::make($file) 
      ->resize(600, null, function ($constraint) { 
       $constraint->aspectRatio(); 
      }) 
      ->save($path.'/micro/'.$article->url);    
     foreach($langues as $key=>$value){ 
      $text=TextArticle::firstOrNew(['idlangue' => $value->id,'idarticle'=>$id]); 
      $text->titre=$request->input('titrel'.$value->id); 
      $text->save(); 
     }    
     DB::commit(); 
     } 
     catch(Exception $e){ 
      DB::rollBack();     
     } 
     $categorie=Categorie::find($article->idcategorie); 
    return redirect("/categorie/".$categorie->libelle); 
} 

感谢您事先:)

回答

1

使用本:

if ($request->hasFile('upload')) { 
//your code 
} 

它应该工作:)

+0

谢谢你=)没关系 –