我正尝试将图像直接上传到保管箱,我也使用croppie,所以 我的laravel上传代码是:
$user = User::find($request->id_user);
$image = $request->image;
list($type, $image) = explode(';', $image);
list(, $image) = explode(',', $image);
$image = base64_decode($image);
$image_name = $user->rut.'_'.'photo'.'_'. date("d_m_Y") .'.jpg';
$path = public_path('temp_images/'.$image_name);
Storage::disk('dropbox')->putFileAs(
'/intranet_jisparking_pictures/',
$image,
'image.jpg'
);
问题是它在字符串上显示对成员函数getRealPath()的调用
我该如何解决?谢谢!
答案 0 :(得分:0)
这是putFileAs
类中Illuminate\Filesystem\FilesystemAdapter
方法的标头:
/**
* Store the uploaded file on the disk with a given name.
*
* @param string $path
* @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile $file
* @param string $name
* @param array $options
* @return string|false
*/
public function putFileAs($path, $file, $name, $options = [])
看起来第二个参数应该是File
或UploadedFile
,但是您给它的结果是字符串的base64_decode。
解决此问题的一种方法是在一个临时文件中自己创建一个UploadedFile
的实例。有关示例,请参见this answer。