我试图将上传到表单的图像转换为 Laravel 中的 Base 64,但上传的图像为空
刀片文件-->(查看)
<body>
<form action="{{Route('PostImageProcess')}}" enctype='multipart/form-data'>
{{ csrf_field() }}
<div class="form-group">
{{-- {!! Form::label($for, $text, [$options]) !!} --}}
<label for="img">post Image</label>
<input type="file" name="image" id="img">
</div>
<input type="submit">
</form>
</body>
内部控制器-->
public function PostImageProcess(Request $request){
// $image = base64_encode(file_get_contents($request->file('image')));
$ima= base64_encode(file_get_contents($request->file('image')));
echo $ima;
$image="11221";
return view('afterPostSuccess')->with("body",$image);
}
我收到此错误: file_get_contents(): 文件名不能为空
达令说