2016-10-27 18 views
0

私は自分のフォームでmultiUpload画像システムを作成しています、私は、ユーザーが4つの異なる入力に4枚の画像をアップロードし、その画像を保存することができますことをしたいが、私はこのエラーがあります:Laravel 5.2 - multiUpload画像とエラー配列

NotReadableException in C:\xampp\htdocs\regalo\vendor\intervention\image\src\Intervention\Image\AbstractDecoder.php line 302: Image source not readable

MY FORM

{!! Form::open(array('url'=>'crea-regalo','method'=>'POST','class' => 'form-horizontal', 'files'=>true)) !!} 

<!-- photo --> 
<div class="form-group"> 
    <label class="col-md-3 control-label" for="textarea"> Picture </label> 
    <div class="col-md-8"> 

    <div class="mb10"> 

    <input id="input-upload-img1" name="image[]" type="file" class="file" data-preview-file-type="text"> 
    </div> 

    <div class="mb10"> 

    <input id="input-upload-img2" name="image[]" type="file" class="file" data-preview-file-type="text"> 
    </div> 


    <div class="mb10"> 

    <input id="input-upload-img3" name="image[]" type="file" class="file" data-preview-file-type="text"> 
    </div> 


    <div class="mb10"> 

    <input id="input-upload-img4" name="image[]" type="file" class="file" data-preview-file-type="text"> 
    </div> 

{!! Form::close() !!} 

MY CONTROLLER

  foreach ($request->image as $imageArray){ 

      // get file 
      $file = $request->file('image'); 
      // create istance - Maybe here start the problem, doesn't get the files images 

      $image = image::make($imageArray); 
      // create path 
      $path = public_path().'/images/post/'.$get_post_created->id; 
      // rename file 
      $name_file = $get_post_created->id . '.' . $imageArray->getClientOriginalExtension(); 

      // resize 
      $image->resize(100,100); 
      // save 
      $image->save($path.$name_file); 
      // store path reference 
      $store_path = new ImageUpload(); 
      $store_path->path = 'images/post/'.$get_post_created->id.'/'.$name_file; 
      $store_path->post_id = $get_post_created->id; 
      $store_path->save(); 
     } 

私は4つの入力の2枚の画像をアップロードしようとしました。:

public function creaPost(Request $request){ 
dd ($request->image); 
.... 
... 
} 

enter image description here

私がわからない場合は入力名=「画像[]」配列は細かいファイルを取得している、または多分私は私のコントローラでforeachのサイクルでいくつかの問題を抱えています。ご協力ありがとうございました!

答えて

0

の代わりに、この $image = Image::make($file->getRealPath())を試してみてください、あなたの$image = image::make($imageArray); 次に、あなたがイメージしてやりたいと、あなたのコードでそれを保存することができます$image->save($path.$name_file);