Simplest way to upload a file to AWS S3 via PHP
Use the steps below to help you get started on uploading a file using PHP with S3.
Download the AWS SDK for PHP via composer
Note: If you still don’t have composer in your system or if you are using Windows, download the installer here -> https://getcomposer.org/download/
Then, run the following command
composer require aws/aws-sdk-php
Create a sample php file(e.g. test.php) and use this code.
Note: For the credentials part, you can get or generate it on the “Your Security Credentials” section of AWS.
Go to “Access keys (access key ID and secret access key)” and hit “Create New Access Key”
Hit on the “Show Access Key” to reveal the Access ID and Secret Key.
You should now be able to access the test page via browser or terminal and be able to see the file on the S3 target location. Like so,
Note: here’s a sample code where you will be using a PHP upload mechanism and have the file transferred directly to S3.