[英]Call to undefined method Intervention\Image\ImageManager::upload()
I am trying to upload an image into my database. 我正在尝试将图像上传到数据库中。 When i do upload, i get this error below
当我上传时,出现以下错误
Call to undefined method Intervention\\Image\\ImageManager::upload()
调用未定义的方法Intervention \\ Image \\ ImageManager :: upload()
Searching on the internet for solutions, i found this method 在互联网上搜索解决方案,我发现了这种方法
adding this line 'Intervention\\Image\\ImageServiceProvider' in my $providers in config/app.php
adding this line 'Image' => 'Intervention\\Image\\Facades\\Image' in my $aliases in config/app.php
'Intervention\\Image\\ImageServiceProvider' in my $providers in config/app.php
添加这行'Intervention\\Image\\ImageServiceProvider' in my $providers in config/app.php
'Image' => 'Intervention\\Image\\Facades\\Image' in my $aliases in config/app.php
添加此行'Image' => 'Intervention\\Image\\Facades\\Image' in my $aliases in config/app.php
In my controller as well, i have use Image. 在我的控制器中,我也使用了Image。 But then i am still getting this error above.
但后来我仍然在上面出现此错误。 What could i be missing please?
我可能想念什么?
Controller 调节器
public function uploadImagePost(UploadUserImageRequest $request)
{
$user = Auth::user();
$image = $request->file('profile_image');
if (false === empty($user->image_path)) {
$user->image_path->destroy();
}
$relativePath = 'uploads/users/' . $user->id;
$path = $relativePath;
$dbPath = $relativePath . DIRECTORY_SEPARATOR . $image->getClientOriginalName();
$this->directory(public_path($relativePath));
Img::upload($image, $path);
$user->update(['image_path' => $dbPath]);
return redirect()->route('my-account.home')
->with('notificationText', 'User Profile Image Uploaded successfully!!');
}
Library you have used doesn't have upload() method. 您使用的库没有upload()方法。 Use save() method for saving the file.
使用save()方法保存文件。
// read image from temporary file
$img = Image::make($_FILES['image']['tmp_name']);
// save image
$img->save('foo/bar.jpg');
Refer this link for more details 请参阅此链接以获取更多详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.