Good evening, I would like to add the resize function of the images when an image is uploaded on my site, I have installed the necessary dependencies and I have included in the config/app files the provider and the aliases. But I find this error: production.ERROR: Method Illuminate\Http\UploadedFile::resize does not exist.
I put the part of the code below:
public function imageProfile(Request $request)
{
$user = Auth::user();
$rules = array(
'profile-image' => 'required|image|mimes:jpeg,png,jpg,gif|max:8192|dimensions:min_width=160,min_height=160',
);
$customMessages = [
'profile-image.required' => 'E\' richiesta una immagine per cambiare immagine di profilo.',
'profile-image.image' => 'Devi inserire un immagine valida.',
'profile-image.mimes' => 'L\'immagine inserita non ha un formato adatto.',
'profile-image.dimensions' => 'L\'immagine deve essere minimo 160x160.',
];
$validator = Validator::make(Input::all(), $rules, $customMessages);
if ($validator->fails()) {
return response()->json(['success' => false, 'error' => $this->validationErrorsToString($validator->errors())]);
}
if ($request->hasFile('profile-image')) {
$number = mt_rand(1,1000000);
$image = $request->file('profile-image');
$name = $user->username.'-'.Carbon::now()->toDateString().'-'.$number.'.'.$image->getClientOriginalExtension();
$destinationPath = 'uploads/profile';
$imagePath = $destinationPath. "/". $name;
$image->move($destinationPath, $name);
$image->resize(200,200);
$user->image_profile = $imagePath;
$user->save();
$html = $imagePath;
return response()->json(['success' => true, 'html' => $html, 'image' => $imagePath]);
}
}
Thanks for help me, and have a good day
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2J0uGhj
via IFTTT
Aucun commentaire:
Enregistrer un commentaire