MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Upload Profile Image of Users in LARAVEL?

How to Upload Profile Image of Users in LARAVEL?

Step 1. Create a new Project in Laravel, so open git bash. Write down the following command:-

$ composer create-project --prefer-dist laravel/laravel ProfileImage "5.8.*"Code language: JavaScript (javascript)
Git Bash running composer create-project to create the Laravel 5.8 ProfileImage project

Step 2.  Now, Move to project directory on git Bash, so write down the following command:-

$ cd ProfileImage
Git Bash running cd ProfileImage to move into the new Laravel project directory

Mysql Database connection Laravel

Step 3. So, Create a Database for this and Go to XAMPP server->phpMyAdmin->Click New Database->imagedatabase.

PhpMyAdmin Databases tab creating a new database named imagedatabase

Step 4.  Go to .env file to set the project path and give the project DB_DATABASE name and DB_USERNAME name.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=imagedatabase
DB_USERNAME=root
DB_PASSWORD=

Step 5.  Create the user authentication scaffolding and write down this command:-

$ php artisan make:auth
Git Bash running php artisan make:auth with Authentication scaffolding generated successfully

Step 6. Add image column with default value into database/migrations/create_users_table.php

   $table->string('image')->default('user.png');Code language: PHP (php)

Step 7. Migrate the tables into the MySQL database. Write the following command in git Base.

$ php artisan migrate
Git Bash running php artisan migrate, creating users and password_resets tables successfully

Step 8. Link the storage directory. Write the following command:-

$ php artisan storage:link
Git Bash output of php artisan storage:link confirming the public/storage directory has been linked

Step 9. Go to resources/views/home.blade.php file.

Step 10. Go to User.php file and write down the following code:-

Step 11. Go to layouts/app.blade.php file and write down the following code:-

Step 12. Now, Go to app/Http/Controllers/HomeController.php file

Sublime Text showing HomeController.php upload method that stores the image and updates the user record

Step 13. Then, go to routes/web.php file and define the route.

Step 14. After that, Use these classes into routes/web.php file

Upload Profile Image
Laravel dashboard with default avatar in the navbar and a Choose File and Upload profile image form
Laravel dashboard showing the newly uploaded profile photo in the navbar after upload

Thanks

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

How to Display Recent and popular data from Database using left join and OderBy

Fist Step In Welcome.blade.php file for Table Secound Step In Pages.blade.php Third Step In Routing, Go To web.php Forth Step In GestController.php This is Return $gallery View…

Read More

How to Delete Multiple Records using Checkbox in Laravel?

It’s almost need to give feature for remove multiple records using checkbox, if you are developing e-commerce application or any big web application then you must give…

Read More

Basic Things To Find Error In Laravel

To be master in finding error and build logic to make query, certain things should understand properly (i) check wheather your routing working properly or controller working…

Read More

How to merge two or multiple tables to each other in the Laravel PHP Framework? (Part-3)

Part-1 Part-2 Now, we’ll create the 2nd table State to merge with the Country table. Step 1. Create child file resources/views/State folder with name create.blade.php. Step 2. Create edit.blade.php file. In this…

Read More

How to use Search Functionality in Laravel?

How to use Search Functionality in Laravel? Step 1. Create a new Project in Laravel, so open git bash. Write down the following command:- Step 2. Now, Move to project directory on git Bash,…

Read More

How to Update Name and Email of Users in Laravel?

How to Update Name and Email of Users in Laravel? To know the Creation of project, User Authentication, Database Connection, Migration of tables. CLICK. Step 1. Go…

Read More