Laravel 5 未定义变量:数据(laravel多重图像上载)

Laravel 5 未定义变量:数据(laravel多重图像上载),laravel-5,Laravel 5,这是我的多图像上传控制器,我得到一个错误,说,数据是未定义的json_编码(数据),一些能给我一个解决方案吗 试试这个 $data = []; if($request->hasfile('image') as $image){ foreach($request->file('image') as $id => $image){ $ext = $image->getClientOriginalExtension();

这是我的多图像上传控制器,我得到一个错误,说,数据是未定义的json_编码(数据),一些能给我一个解决方案吗

试试这个

$data = [];

    if($request->hasfile('image') as $image){
     foreach($request->file('image') as $id => $image){
                $ext = $image->getClientOriginalExtension();
                $name = $id.time().'.'.$ext;
                $path = public_path('\property\');
                $image->move($path, $name);
                $data[$id] = $name;
            }
    }

请添加代码而不是图像