我正在使用 Laravel 和干预来处理来自用户的文件上传,我已经使用 Composer 安装了干预,但是当我尝试使用它的一些功能时,我收到了这个错误消息Class 'Intervention\Image\Facades\Image' not found
我检查了我的 app.php 文件并添加了正确的别名和提供者的代码行,但现在我不确定是什么问题
这是我的功能
public function postAvatarUpload(Request $request)
{
$this->validate($request, [
'image' => 'required|image|max:3000|mimes:jpeg,jpg,png',
]);
$user = Auth::user();
$usersname = $user->username;
$file = $request->file('image');
// $ext = $file->getClientOriginalExtension();
$ext= Input::file('image')->getClientOriginalExtension();
$filename = $usersname . '.' . $ext;
if (Storage::disk('public')->has($usersname)) {
Storage::delete($usersname);
}
Storage::disk('public')->put($filename, File::get($file));
$path = public_path('app/public/'. $filename);
Auth::user()->update([
'image' => $path,
]);
$resizedImg = Image::make($path)->resize(200,200);
// $ext = $file->getClientOriginalExtension();
return redirect()->route('profile.index',
['username' => Auth::user()->username]);
}