在 Larael base64 编码的字符串上调用成员函数 move()
Call to a member function move() on string Larael base64 encoded
我正在使用 API 和 base64 编码格式从 Android phone 获取照片。
拿到照片后,我必须调整它的大小。但我收到错误。请帮忙解决。
$image = $request->photo; // my base64 encoded
$image = str_replace('data:image/jpg;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imagename = 'prsn-'.time().'.jpg';
$destinationPath = public_path('/thumbnail');
$img = Image::make($image);
$img->resize(150, 150, function ($constraint)
{
$constraint->aspectRatio();
})->save($destinationPath.'/'.$imagename);
$destinationPath = storage_path('local');
$image->move($destinationPath, $imagename); /*** <<<<<<< getting error on this line ***/
$input = $request->all();
$input['photo'] = $imagename;
Contact::create($input);
问题已使用以下代码解决
$image = $request->photo; // my base64 encoded
$image = str_replace('data:image/jpg;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imagename = 'prsn-'.time().'.jpg';
$destinationPath = public_path('/thumbnail');
$img = Image::make($image);
$img->resize(150, 150, function ($constraint)
{
$constraint->aspectRatio();
})->save($destinationPath.'/'.$imagename);
$destinationPath = public_path('/images');
Image::make($image)->save($destinationPath.'/'.$imagename);
$input = $request->all();
$input['photo'] = $imagename;
Contact::create($input);
感谢所有愿意提供帮助的人,特别感谢:porloscerros-Ψ的意见和建议
我正在使用 API 和 base64 编码格式从 Android phone 获取照片。 拿到照片后,我必须调整它的大小。但我收到错误。请帮忙解决。
$image = $request->photo; // my base64 encoded
$image = str_replace('data:image/jpg;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imagename = 'prsn-'.time().'.jpg';
$destinationPath = public_path('/thumbnail');
$img = Image::make($image);
$img->resize(150, 150, function ($constraint)
{
$constraint->aspectRatio();
})->save($destinationPath.'/'.$imagename);
$destinationPath = storage_path('local');
$image->move($destinationPath, $imagename); /*** <<<<<<< getting error on this line ***/
$input = $request->all();
$input['photo'] = $imagename;
Contact::create($input);
问题已使用以下代码解决
$image = $request->photo; // my base64 encoded
$image = str_replace('data:image/jpg;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imagename = 'prsn-'.time().'.jpg';
$destinationPath = public_path('/thumbnail');
$img = Image::make($image);
$img->resize(150, 150, function ($constraint)
{
$constraint->aspectRatio();
})->save($destinationPath.'/'.$imagename);
$destinationPath = public_path('/images');
Image::make($image)->save($destinationPath.'/'.$imagename);
$input = $request->all();
$input['photo'] = $imagename;
Contact::create($input);
感谢所有愿意提供帮助的人,特别感谢:porloscerros-Ψ的意见和建议