上传到服务器后,Image :: make无法正常工作

时间:2019-03-23 22:09:07

标签: laravel server intervention

当我在服务器上运行项目时,没有问题,一切正常。但是上传到服务器后,Image::make()行中有问题。

try{
    $photo = Image::make($request->photo)->fit(300, 300);
    $photo_name = Str::slug($user->name, '-')."-".Str::slug($user->surname, '-')."-photo-".now()->format('Y-m-d-H-i-s')."-300x300.".$request->photo->extension();
    $photo_path='files/user/picture/'.$photo_name;
    $photo->save($photo_path);
}
catch (\Exception $e){
    report($e);
    return response([
        'error' => $e,
        'message' => 'Photo could not uploaded'
    ],Response::HTTP_NOT_IMPLEMENTED);
}

我收到此错误:

{
   "error": [],
   "message": "Photo could not uploaded"
}

pip.ini:

memory_limit = 350M
post_max_size = 300M
upload_max_filesize = 300M

但是,如果像这样更改源代码,就没有问题,图像正在上传。

try{
    $photo = $request->photo;
    $photo_name = Str::slug($user->name, '-')."-".Str::slug($user->surname, '-')."-photo-".now()->format('Y-m-d-H-i-s')."-300x300.".$request->photo->extension();
    $photo_public_path = public_path('files/user/picture/');
    $photo_path = 'files/user/picture/'.$photo_name;
    $photo->move($photo_public_path, $photo_name);

}
catch (\Exception $e){
    report($e);
    return response([
        'error' => $e,
        'message' => 'Photo could not uploaded'
    ],Response::HTTP_NOT_IMPLEMENTED);
}

0 个答案:

没有答案