Laravel 7 Ajax Image Upload

Siddharth Shukla
1 min readMar 8, 2020

--

Step 1: Install Laravel 7 Project

I am going to install a laravel project using composer.

composer create-project --prefer-dist laravel/laravel laravel7

Step 2: Going inside of project using the command

cd laravel7

Step 3: Setup MySQL database

Now, configure this database in the .env file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel7
DB_USERNAME=root
DB_PASSWORD=root@123

Step 4: Create employee_images Table and Model also.

Here, I have created migration for employee_images using Laravel 7 php artisan command, you can check command below.

php artisan make:migration create_employee_image_tabel

Once this command is done open file database/migrations and put code inside of migration file.

public function up()
{
Schema::create('employee_images', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('image');
$table->timestamps();
});
}

Now run migration command:

php artisan migrate

Step 5: Create a Model

After creating “employee_images” table you should create EmployeeImage model. So first we have to run bellow laravel artisan command for creating EmployeeImage model:

php artisan make:model EmployeeImage

Find a file inside of app folder

Read More: https://realprogrammer.in/laravel-7-ajax-image-upload/

--

--

Siddharth Shukla
Siddharth Shukla

Written by Siddharth Shukla

I'm a Full Stack Engineer based in India ☀️, working at Kreativ Street. I'm a coding passion focused on Python, specifically Laravel & Django.

No responses yet