Laravel 5.2干预图像 - 500内部服务器错误 - VerifyCsrfToken.php中的TokenMismatchException

时间:2016-05-17 13:40:27

标签: laravel laravel-5.2

如果我对这行代码$this->resizeProfilePhoto($file)发表评论我没有任何令牌错误,但这有什么问题?

public function updateProfilePhoto(Request $request)
{
    $this->validate($request, [
        'profilePhoto' => 'required:mimes:jpg,png,bmp'
    ]);
    $user = User::find(Auth::user()->id);
    $file = $request->file('profilePhoto');
    //$this->resizeProfilePhoto($file);
    $newName = md5(time() . $file->getClientOriginalName()) . str_random(15) .'.jpg';
    $user->photo_path = $newName;
    $file->move(
        (User::PHOTO_PATH), 
        User::userPhoto($user, 'orginal')
    );
    $user->save();
    return 'Done';
}
public function resizeProfilePhoto($file)
{
    try
    {
        $img = Image::make(
            $file->getRealPath()
        );
        $img->fit(200);
        return $img->save(public_path('images') .'/'. 'test.jpg');
    }
    catch(Exeption $e)
    {
        return false;
    }
}

0 个答案:

没有答案