Skip to main content

Posts

Showing posts with the label Laravel File Upload

How to Upload and Store Files on AWS S3 in Laravel

How to Upload and Store Files on AWS S3 in Laravel Uploading files to AWS S3 is a common requirement in modern Laravel applications. Amazon S3 provides scalable, secure, and cost-effective cloud storage for files such as images, documents, and media assets. Prerequisites A Laravel application An AWS account An S3 bucket created in AWS Step 1: Install AWS S3 Driver Install the Flysystem AWS S3 package using Composer: composer require league/flysystem-aws-s3-v3 "^3.0" Step 2: Configure AWS Credentials Add the following configuration values to your .env file: AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET=your_bucket_name AWS_USE_PATH_STYLE_ENDPOINT=false Tip: Always keep your AWS credentials private and never commit them to GitHub. Step 3: Configure the S3 Filesystem Disk Open the config/filesystems.php file and make sure the S3 disk is configured correctly: ...