Laravel User Image
HTML-код
- Опубликовано: 14 май 2016
- devdojo.com/ninja - Learn how to create your own Software as a Service in my Ninja Training Program.
devdojo.com/episode/laravel-u... In this video we'll teach you how to add a user profile image in your Laravel App.
Checkout the following repo for the source code: github.com/thedevdojo/laravel...
Great video. It's refreshing to hear someone speaking clear english on Laravel tutorials!
relatable wtf
Ditto!
so true. Im not a native englsih speaker and its sometime hard to understand
All hail devdojo, this is exactly what I was looking for!
Great channel for novice. Thanks Tony!
Great! It's working perfectly.
I added it to my Laravel best youtube videos playlist ;)
Thanks very much, love the video Tony. Hope to have more. Keep it coming!
Интересный и полезный курс, спасибо большое автору !!!
Excellent tutorial. Thanks so much for doing this.
nice tutorial, learned a lot, clear and easy to learn
Worked like a charm ! Thank You.
You make it look so simple thanks :)
Great video , also working in laravel 6 , keep giving like this tutorial
Thank you so much. You have helped me a lot with this video.
Amazing Tutorial :)
Thank you very much
Awesome! Thank you for sharing!
This is great! I want to learn more :)
This is very informative and helpful tutorial thanks alot
this was so useful, thanks
Awesome !
It work, thank you so much guy.
impressed the way you explained (y)
I really wanna thank you for these wonderful tutorials you make. Truly Inspiring.
THANK YOU :)
Bro, please help me
it still shows the image of 09:03.
How did you fix it ?
+Tetike Try not spamming all the users :) Thanks.
+devdojo Sorry :( I just wanted to fix it
forgive mr
Thang you for the great tutorial! :)
Here is a little addition to make it even better .. Just before Image::make($avatar) add the following:
// Delete current image before uploading new image
if ($user->avatar !== 'avatar.png') {
$file = public_path('uploads/avatars/' . $user->avatar);
if (File::exists($file)) {
unlink($file);
}
}
So every time the user uploads a new photo the old one will be deleted for your server
could you show your all your code for this function as it doesn't work for me just keeps deleting the current image , i might have the order in the wrong way as within the if statement , thx
public function updateUserAvatar(Request $request)
{
$user = User::find(Auth::user()->id);
// Handle the user upload of avatar
if ($request->hasFile('avatar')) {
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
// Delete current image before uploading new image
if ($user->avatar !== 'default.png') {
// $file = public_path('uploads/avatars/' . $user->avatar);
$file = 'uploads/avatars/' . $user->avatar;
//$destinationPath = 'uploads/' . $id . '/';
if (File::exists($file)) {
unlink($file);
}
}
// Image::make($avatar)->resize(300, 300)->save(public_path('uploads/avatars/' . $filename));
Image::make($avatar)->resize(300, 300)->save('uploads/avatars/' . $filename);
$user = Auth::user();
$user->avatar = $filename;
$user->save();
}
return view('subscription.profile', compact('user'));
}
sorry I just gave you the entire thing ... At least you are able to see where i insert the piece of code (y)
haha na that's fine you fixed my problem which I really appreciate , I only check for user auth in the return method thats' why i was getting an error with the unlink method as i didn't know which user Id to unlink the image , thx
How to use or get User::find ? I have an error that the User controller is not define. Thanks in advance.
Thanks alot, still working with 5.4!
Very helpful. Many thanks.
Solved the problem ! Thanks!
Nice and beautiful work
Allah razı olsun çok işime yaradı.
thanks so much for the video helped alot!!
it is working. thank you dojo 👈
VERY GOOD,thanks your video
Great video, thanks.
Thank you :)
this video is very uselful
thanks dude, your awesome!
great video !!! you are the best!
Great video !
Thanks! It helps me a lot :) God bless!
Really amazing Thank you
You are a Star!
this was helpful thanks ^^
Thank you for this
this really helped me thanks :) .. keep it up (Y)
Great job
Im testing at larevel 5.5 . It works. Thanks & subscribing. A big help for me. The only problem is if you keep pressing the button for a SUBMIT. no image appears.
I have the same problam Sir, have u solved it ?
your contain enctype="multipart/form-data"?
Great! Thank You!
you are the best!
Bro, please help me
it still shows the image of 09:03
How did you fix it
+Tetike Try not spamming all the users :) Thanks.
Great video
Thankyou broo!🙌
It's works for laravel v5.6!
soy el único que sabe español acá? jajajaja si lees esto eres el puto amo! gracias...
Very helpful video and just saying Allah bless you
Thanks man
you are the best
thank you a lot is working 1000%%%%%%
thx for video, very appreciated! btw, probably would be nice to delete avatar from storage when replacing it with new one.
if($user->avatar !== 'avatar.png') {
// if not default avatar
\Storage::disk('avatars')->delete($user->avatar);
}
To create disk you can put it into /config/filesystems.php
'avatars' => [
'driver' => 'local',
'root' => public_path() . '/images/avatars',
// you can have other path
'visibility' => 'public',
],
is that "handsome looking guy" you? :) nice tutorial
Great tutorial. Can you make a video on how to crop the uploaded image using jcrop or any other? Because many a times the default aspect ratio is square and user uploads image of some other aspect ratio so by default it gets stretched or something.
Thanks in advance.
Thx soooo much
Thanks bro
hello sir i need your help . i want to know how to build the same thing as u have shown but without using any package
Would you be able to create videos on how to add tags from a database onto posts in the newsfeed (like the tags in StackOverflow)?
Nice 👌👌👌👌
Hello, ty for the vid, really help me!. i have a question, how can i store the imagen in storage folder, and show it from there? ty in advance
Muito bom.
awesome bro
Bro, please help me.
It still shows me the picture of 09:03
Please tell me how did you fix it
+Tetike Try not spamming all the users :) Thanks.
I'm using Voyager, so `intervention/image` was already installed. Also it stores the photos in `storage\users` folder. Need videos about integration Voyager avatar function and front-end
wow ,thanks, suscribe
Thank you so much for this great tutorial. I have small issue, I am working localhost and image path is not correctly written in the mysql db. Sample of the image path in the db "C:\xampp\tmp\phpA49.tmp" can you please help
Hey do you have any tutorials on how to make so the main page changes when you log in, for an example i don't want their to be a log in button when i have already logged in. If so i would be greatful!
HI! Thank You!
What about adding filetype validation here?
thx!
How can I possible adapt it to my Laravel CRUD without the Users Auth?
Addition:
You can use exif_read_data() results to rotate the image (for example if you get images from a mobile phone).
Example:
$exif = @exif_read_data($file);
if (isset($exif['Orientation']) && $exif['Orientation'] == '8') {
Image::make($pathTMP)->rotate(90)->save($pathOrg);
}
Hello Tony,
Nice video!
Woud you know how does Laravel Spark get the cache picture of my gmail? I did not even upload any photo and it brough the image... any tips on that?
Thanks!
I have a question. I created a product view with model and controller. then I created a blade template which holds a thumbnail and gets the data obj from product controller. Now when I include my product.blade.php in the welcome.blade.php it covers everyone on my welcome page. If I remove the data obj i can see it display the thumbnail using a simple for loop.
Thnx
(1/1) NotFoundHttpException
in RouteCollection.php (line 179)
this error occurs while make a profile page
Good night Sir Sory Im From indonesia I hope you can help me how to display a flash notification message to a specific time in laravel 5.2
hey have you guys done any videos on vue js?
hey bro, thanks for the tutorial, but i have a problem, my avatar didn't update, no error, can you help me?
NotFoundHttpException in RouteCollection.php line 161:
I am keep getting this error does anyone know why ?
thks
Hey devdojo, Could you please tell me how can i link the above tutorial of User's Profile Image with your chatter package..? Thanks in advance :D
which error occur when file size is too large
THANKYOUUUUUUUUUUUU :'>
after submit it shows
(1/1) NotWritableException
Can't write image data to path (D:\wamp\www\project\public\/uploads/page/small/1509780886.jpg)
how to delete photos from the folder when the user changes its profile?
which version of laravel you are used????
am using windows 10 and get this error
Unable to read image from file ().
any suggestions ?
please show us how to make a photo galleries, thanks
how will I be able to use this in ajax?
Are you saving the image in the database?
or youRE saving it in another folder and just saving the file name of the image?
Filename is saved in the database the .jpg itself is saved in the folder '/uploads/avatars' so 'or youRE saving it in another folder and just saving the file name of the image?'
sir ,
when I try to submit profilr image I am getting this error-
"Call to a member function getClientOriginalExtension() on boolean"
Helo sir
i got problem.. why your code got looping.. if user return view to profile page again and when they click button refresh it will submit again and then the image upload will upload again. when click refresh it will detech resubmision form.. why?
Hello sir,
I have performed all the steps which you telling us but at profile upload it not working it gives a error like
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
can you make a tutorial again with this topic?
Hi im working in laravel 8 but i cant get the use Image to work, it says its not defined
How can I upload each user profile pictures in separate folder, because later it will be a mess...
Been Trying this several time for the user registration page but every time i try i keep getting this error message "Call to a member function hasFile() on array" and am kind of stuck kindly help please
update_avatar doesnt work in my app
when i change the default avatar nothing appears
Class 'Image' not found error. Please help me resolve this. And i am using laravel 5.3