Laravel 7 Ajax Image Upload
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/