2016-10-27 5 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

МОЯ ФОРМА

{!! 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() !!} 

мой контроллер

  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(); 
     } 

Я пытался загрузить 2 изображения из 4 входов:

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

enter image description here

Я не знаю, если имя входного = «изображение []» массив получает штраф файлы, или, может быть, у меня есть некоторые проблемы в Еогеаспе цикле в моем контроллере. Спасибо за помощь!

ответ

0

Попробуйте $image = Image::make($file->getRealPath()) вместо вашего $image = image::make($imageArray); Тогда вы можете делать то, что вы хотите с изображения и сохранить его с кодом $image->save($path.$name_file);

Смежные вопросы