2016-12-07 11 views
1

私はコントローラbase64で画像を入力しています。画像のサイズを変更するには介在画像を使用しています。画像を保存します。 PostController.php線163にLaravel 5.2 - 介入画像、base64入力画像を保存

ErrorException:BASE64_DECODE()は パラメータ1が

public function creaPost(Request $request){ 
    $image_array = $request->input('image'); // input image base64 
    $contare = count($image_array); 

    for($i = 0; $i < $contare; $i++) { 

         $file = base64_decode($image_array[$i]); 

         if (!empty($file)) { 


         $background = Image::canvas(550, 550); 
         $image2 = Image::make($file)->encode('jpg', 100)-     >resize(550, 550, function ($c) { 
         $c->aspectRatio(); 
         $c->upsize(); 
         }); 
         ... my code...etc.. 
         $store_path->save(); 

         } 
    } 
} 

ライン$file = base64_decode($image_array[$i]);リターンを与えられた文字列、アレイであることを期待し、私は、デコード画像BASE64といくつかの問題を抱えていますエラー、私はどのように私はよく私の配列の画像をデコードすることができますかわからない。

私がしなければMAYBE を助けることができる:

$image_array = $request->input('image'); 
return dd($image_array[1]); 

リターンこの: enter image description here

答えて

0

使用

foreach($image_array as $key => $image) { 
    $file = base64_decode($image); 

エラーは、あなたが数値を使用しているあなたのforループで原因を発生します、あなたの$image_arrayには数値以外のインデックスがあります。最初のインデックスは0ではなく、dsdas.PNG