Amazon S3 File Transfer Documentation

Version 1.0.0 Last Documentation Update - 28/10/2020


Thank you for purchasing Amazon S3 File Transfer Php Script. We covered almost everything in this document that how easily you can setup this script. We really do appreciate every sale. If you like our work please do not forget to rate it. It helps us in developing new and better cloud solutions.

Author: Berkine
Demo: Amazon S3 File Transfer Demo
Admin Panel: Amazon S3 File Transfer Admin Demo


Before installation, your server must have following requirements to run the script properly
  • PHP v7.2 or higher
  • PHP Mbstring Extension
  • PHP PDO Extension
  • PHP JSON Extension
  • PHP CURL Extension
  • Support for MySQL v5.x
  • AWS Account with Root or Admin Level Access
  • AWS IAM User with S3 Read and Write Access

AWS PHP SDK (Version 3)

The AWS PHP SDK v3 comes already included with the script, under - "vendor/aws" folder in the root directory of the app. And it is the offical latest AWS PHP SDK without any modification.

If you prefer to install AWS PHP SDK manually or to update to the latest version, you can get it from here: AWS PHP SDK Download

Installation Instructions

This is a general installation overview of the script, there is a deep dive section provided for each part in the left menu bar.

Follow the steps as explained, and you should be all set. If you face any challenges with installtion steps, reach out to us for a support.

Setup overview:

  • Step 1: Unzip S3 File Transfer to the root directory of your hosting - Ex: /var/www/html/. Which will make it reachable as follows: http://yourwebsitename/s3
  • Step 2: After unzipping files, run install.php file to configure your MySQL Database settings.
  • Step 3: (Optional) MySQL Database settings can also be configured manually as explained in notification.php file.
  • Step 4: Import the provided database/import_tables.sql database to the same database that you showed under DB Name in previous steps.
  • Step 5: (Optional) If step 2 was completed successfully and you were redirected to index.php page, you can delete install.php and notification.php files.
  • Step 6: Login into Admin Panel by visiting http://yourwebsitename/admin/ page. Use following credentials to login: LOGIN: admin and PASSWORD: 123456. You can change your login and password in Admin Panel as needed.
  • Step 7: Include your AWS IAM Access Key and Secret Access Key Credentials under AWS Configuration page in Admin Panel. If you need to setup AWS Account and S3 bucket, visit AWS Setup page. Make sure you include your S3 Bucket name as well and select correct AWS Region.
  • Step 8: If you want to see your Google Analytics data as shown in the demo example, follow the instructions under Google Setup page.
  • Step 9: For seting up SMTP configurations, follow the instructions under PHPMailer Setup page.
  • Step 10: Now you should be all set, enjoy the script!.

File Structure

General overview of included files:
  • Assets - All Client/server CSS and JS files
  • Classes - Entire script was written with OOP approach, all used classes are stored here
  • Core - Core settings and single file for all included files
  • Includes - Helper files for pages to call proper methods and run CRUD for DB
  • Pages - All Admin Panel pages are stored here
|	index.php
|	MultiparUpload.php
	|   footer.php
	|   header.php
	|   index.php
	|   login.php
	|   logout.php
	|   navbar.php
	|   +---client
	|   |   +---css
	|   |   |       all.min.css
	|   |   |       awselect.css
	|   |   |       bootstrap.min.css
	|   |   |       filepond.css
	|   |   |       responsive-styles.css
	|   |   |       styles.css
	|   |   |
	|   |   +---img
	|   |   +---js
	|   |   |       awselect.js
	|   |   |       bootstrap.min.js
	|   |   |       custom.js
	|   |   |       filepond-plugin-file-validate-size.min.js
	|   |   |       filepond-plugin-file-validate-type.min.js
	|   |   |       filepond.jquery.js
	|   |   |       filepond.min.js
	|   |   |       jquery-3.5.1.min.js
	|   |   |       modernizr.js
	|   |   |       popper.min.js
	|   |   |
	|   |   +---webfonts
	|   |
	|   \---server
	|       +---css
	|       |       all.min.css
	|       |       animate.min.css
	|       |       awselect.min.css
	|       |       bootstrap.css
	|       |
	|       |       Chart.css
	|       |       Chart.min.css
	|       |       datatables.min.css
	|       |       responsive-styles.css
	|       |       styles.css
	|       |
	|       +---img
	|       +---js
	|       |       awselect.min.js
	|       |       bootstrap.bundle.js
	|       |
	|       |       Chart.bundle.min.js
	|       |       Chart.min.js
	|       |       custom.js
	|       |       datatables.min.js
	|       |       jquery-3.5.1.min.js
	|       |
	|       |       loader.js
	|       |       modernizr.js
	|       |       moment.min.js
	|       |       view-selector2.js
	|       |
	|       |
	|       +---webfonts
	|       CloudWatch.class.php
	|       Config.class.php
	|       Cookie.class.php
	|       DB.class.php
	|       Email.class.php
	|       GA.class.php
	|       Hash.class.php
	|       Input.class.php
	|       Redirect.class.php
	|       S3.class.php
	|       Session.class.php
	|       Token.class.php
	|       User.class.php
	|       Validate.class.php
	|       init.core.php
	|       service-account-credentials.json
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   |
	|   \---errors
	|           404.php

Database Setup in phpMyAdmin

To run admin panel properly and fetch the application usega data and to set the settings you will need to setup local MySQL database.

All the necessary tables are provided in the root directory of the application, under database folder in a file called database.sql. You will need to import it into your existing or new database.

How to Import Database in phpMyAdmin:

  • Step 1: Login into phpMyAdmin.
  • Step 2: Click on New button to create a new database.
  • Step 3: Provide database name and select utf8_general_ci as collation and click create button.
  • Step 4: After the new database is created, select Import tab and select import_tables.sql file that comes with the application in database folder, and click on Go button.
  • Step 4: Tables in your newly created database should look like this.

After you have your Database Environment setup, run install.php file :

It will create a new file called dbconfig.core.php under admin/core folder.

  • In install.php file:
  • Set mysql db host address.
  • Set mysql db username.
  • Set mysql db password.
  • Set mysql database name.

AWS Account Creation

Getting started with AWS. If you already have AWS Account, skip to next section.

How to Create AWS Account:

  • Step 1: Open the Amazon Web Services home page.
  • Step 2: Choose Create an AWS Account.
    Note: If you signed in to AWS recently, choose Sign in to the Console. If Create a new AWS account isn't visible, first choose Sign in to a different account, and then choose Create a new AWS account.
  • Step 3: Enter your account information, and then choose Continue. Be sure that you enter your account information correctly, especially your email address. If you enter your email address incorrectly, you can't access your account.
  • Step 4: Choose Personal or Professional.
    Note: Personal accounts and professional accounts have the same features and functions.
  • Step 5: Enter your company or personal information.
    Important: For professional AWS accounts, it's a best practice to enter the company phone number rather than a personal cell phone. Configuring a root account with an individual email address or a personal phone number can make your account insecure.
  • Step 6: Read and accept the AWS Customer Agreement.
    Note: Be sure that you read and understand the terms of the AWS Customer Agreement.
  • Step 7: Choose Create Account and Continue.
  • Step 8: On the Payment Information page, enter the information about your payment method, and then choose Verify and Add.
    Note: If you want to use a different billing address for your AWS billing information, choose Use a new address before you choose Verify and Add
    Important: You can't proceed with the sign-up process until you add a valid payment method.
  • Step 9: Verify your phone number. Enter a phone number where you can be reached in the next few minutes.
  • Step 10: In a few moments, an automated system contacts you.
  • Step 11: Enter the PIN you receive, and then choose Continue.
  • Step 12: On the Select a Support Plan page, choose one of the available Support plans. For a description of the available Support plans and their benefits, see Compare AWS Support plans.
  • Step 13: After you choose a Support plan, a confirmation page indicates that your account is being activated. Accounts are usually activated within a few minutes, but the process might take up to 24 hours.
  • Step 14: You can sign in to your AWS account during this time. The AWS home page might display a Complete Sign Up button during this time, even if you've completed all the steps in the sign-up process.
  • Step 14: When your account is fully activated, you receive a confirmation email. Check your email and spam folder for the confirmation email. After you receive this email, you have full access to all AWS services.

AWS IAM User Creation

You will need IAM user with programmatic access and with S3 Read & Write Policies attached.

Creating AWS IAM Users (via AWS Console):

  • Step 1: Sign in to the AWS Management Console and open the IAM console at
  • Step 2: In the navigation pane, choose Users and then choose Add user.
  • Step 3: Type the user name for the new user. This is the sign-in name for AWS.
    Note: User names can be a combination of up to 64 letters, digits, and these characters: plus (+), equal (=), comma (,), period (.), at sign (@), and hyphen (-). Names must be unique within an account.
  • Step 4: Select the type of access this set of users will have. Select programmatic access.
  • Step 5: Choose Next: Permissions.
  • Step 6: On the Set permissions page, specify how you want to assign permissions to this set of new users. Choose Attach existing policies to user directly
  • Step 7: Seach for AmazonS3FullAccess and select click Next: Review
    Note: If you are familar with IAM Policies, you can create custom policy that will match your needs and security requirements.
  • Step 8: To view the users' access keys (access key IDs and secret access keys), choose Show next to each password and access key that you want to see. To save the access keys, choose Download .csv and then save the file to a safe location.
    Important: This is your only opportunity to view or download the secret access keys, and you must provide this information to your users before they can use the AWS API. Save the user's new access key ID and secret access key in a safe and secure place. You will not have access to the secret keys again after this step.
  • Step 9: Include your Access Key and Secret Access Key to the AWS Credentials Settings tab in the admin panel as shown below.

Include your Access and Secret Access Keys:

AWS Credentials

Amazon S3 Bucket Creation

You will need an S3 Bucket with public read & write access in the region that you prefer.

A bucket is owned by the AWS account that created it. By default, you can create up to 100 buckets in each of your AWS accounts. If you need additional buckets, you can increase your account bucket limit to a maximum of 1,000 buckets by submitting a service limit increase. For information about how to increase your bucket limit, see AWS Service Limits

Create an S3 bucket:

  • Step 1: Sign in to the AWS Management Console and open the Amazon S3 console at
  • Step 2: Choose Create bucket.
  • Step 3: Enter Bucket Name and Select AWS Region where you would like to store your files and click Next. Note: Bucket name must be unique at a global level.
  • Step 4: In the next step, you can leave default settings at it is except CloudWatch Request Metrics. If you want to see S3 Bucket Usage details in Admin Panel under CloudWatch tab, select this feature and click Next.
  • Step 5: In the Set Permissions step, you must turn off at least first 2 options or all 4 if you want to make your S3 bucket completely public.
  • Step 6: Review settings and click Create Bucket.
  • Step 7: Include your Bucket Name and Select your AWS Region in the AWS Credentials Settings tab in the admin panel as shown below.

Include your S3 Bucket Name and select your AWS Region where bucket is hosted:

AWS Credentials

Amazon S3 Bucket Configuration

After successfully creating a bucket, add these addtional features for your S3 bucket.

Check these 2 steps:

  • Step 1: Make sure your Permissions -> Block Public Access looks at least like this, or has all 4 options turned off.
  • Step 2: Add CORS settings as shown below in the Permissions -> CORS Configuration tab and click Save.

Copy paste these CORS settings to your bucket:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="">

Amazon S3 Transfer Acceleration Configuration

Amazon S3 Transfer Accelerate enables fast, easy, and secure transfers of files over long distances between your client and an S3 bucket.

It is a paid S3 feature and it is not enabled nor included by default in this script, it is strictly optional whether or not you want to use it.

Enable Transfer Acceleration feature manually:

It is super easy to setup and configure it by yourself, here is how.

  • Step 1: Copy & paste following line into admin/classes/S3.class.php file after line 68.
    'use_accelerate_endpoint' => true,
    Your S3.class.php file should look like this:
  • Step 2: You will also need to activate it in the Properties tab of your S3 Bucket, under Transfer Acceleration as shown in the picture below.
  • Step 3: And that is it, you are all set for Transfer Acceleration feature.

Google Analytics Tracking Configuration

Analyze in-depth detail about the visitors on your main frontend page.

Setup Google Analytics:

  • Step 1: Visit Google Analytics page.
  • Step 2: On the left menu select Admin.
  • Step 3: Click Create Property, **select Web and then Continue.**.

  • Step 4: After that it will appear screen with information for your website.
  • Step 5: Fill it and then click Create.
  • Step 6: After the tracking site tag is generated, copy and paste Tracking ID into the next step. It will be in the following format - UA-XXXXXXXXX-X
  • Step 7: Include Tracking ID into Google Analytics Tracking ID field in Admin Panel under Google Settings and click Save Changes button.

Google Analytics Service Account

In order to use Google Analytics APIs you will need to enable Google Analytics API and get Service Account credentials in JSON format.

Setup Google Analytics Service Account:

  • Step 1: Go to the Google API Console, click on Library tab on the left. Search for Google Analytics API and Enable it.
  • Step 2: Open the Service accounts page. If prompted, select your existing project or create a new one.
  • Step 3: Click + Create Service Account, enter a name and description for the service account. You can use the default service account ID, or choose a different, unique one. When done click Create.

  • Step 4: After your service account is created, click on Action button(triple dots) and select Create key.
  • Step 5: Select Key type in JSON format and click Create, it will save JSON file on your local file system.
  • Step 6: Upload newly create JSON Key type to Admin Panel under Google Settings as shown below and click Save Changes button.

Google Maps API Key

To use the Maps JavaScript you must have an API key. The API key is a unique identifier that is used to authenticate requests associated with your project for usage and billing purposes.

To Get a Maps API Key:

  • Step 1: Go to the Google API Console
  • Step 2: Click the project drop-down and select or create project for which you want to add an API key and give it a project name.
  • Step 3: If you are using Google API for the first time you will see this screen after creating the project:
  • Step 4: Click Enable Apis and Services button or select Library button on the left.
  • Step 5: Find Maps JavaScript API and enable it as shown below.
  • Step 6: Click the menu button and select Credentials and click Create credentials > API key.
  • Step 7: The API key created dialog displays your newly created API key. Copy and paste it as shown in Step 8. The new API key is listed on the Credentials page under API keys.

    Important: Remember to restrict the API key before using it in production.
  • Step 8: Include the API key in Admin Panel under Google Settings > Google Maps API Key field and click Save Changes button.

Change application restrictions:

Depending on your server/domain configuration the script maybe won't accept the HTTP referrers restrictions so try with changing the application restrictions back to None

Enable Billing on your project:

Sometimes after adding the key these features maybe won't work again. Then depending on the google account associated with the project created and maybe you will need to enable Billing.

Learn more here about it: Billing or here Getting started with Google Maps Platform

Google Adsense Configuration

You can easily include your adsense script with admin panel.

Include Adsense Script:

Copy and paste your script for Left and Right columns in Admin Panel under Google Adsense settings and click save button. Make sure your adsense script has responsive feature turned on.

PHPMailer Configuration

For sending donwload links via email the latest version of PHPMailer is used, included under vendor folder in root directory.

All the SMTP settings can be configured and set in Admin Panel under SMTP Settings.

Required SMTP Settings:
  • SMTP Host
  • SMTP Port
  • SMTP Encryption
  • SMTP EMail Login
  • SMTP EMail Password
You can also add optional SMTP Settings:
  • From Email Address
  • From Name
  • Default Email CC

Include Required SMTP Settings and click Save Changes button:

You can also test your SMTP Settings immediately via Test Email Settings:

If you are planning to use Gmail for sending emails:

In your Gmail Account settings, under Security tab, make sure your Less secure app access feature is turned on.

Email Template

Sent emails do not use individual page for customization.

All CSS and Layout customizations can be done in Email.class.php file, by modifying $content variable.

You can custome the CSS Styles as you prefer, examples are shown below, and also can change order or add new HTML Tags as needed to meet your needs.

<!-- Include Email From Address and File Quantity Details, and also Title -->	
$content = "<html><body style='margin:0; padding:5rem; background-color:#ECF4F7;'>
		<div style='width:600px; min-width:600px; margin: 2rem auto; padding: 3rem; background-color:#FFFFFF; border-top: 7px solid #0e2e40;'>
		<h2 style='color:#0e2e40;text-align:center;font-weight:800; font-size:16px; margin-bottom:1rem;'>Upload & Share</h2>
		<h2 style='color:#0e2e40;text-align:center;font-weight:600; font-size:14px;'>" . $emailFrom . "</h2>
		<h2 style='color:#0e2e40;text-align:center;font-weight:600; font-size:14px; border-bottom: 1px solid #e1dfdd; padding-bottom:2rem;'>Has transfered you some files to download</h2>					
		<table style='border: none; border-collapse: collapse;'>
		<tr><td style='line-height:70px; width:100%;'><strong>Total shared files: </strong>" . $fileQuantity . "</td></tr>";

<!-- Include File Names and Downlaod Links -->
$all_links = explode(';', $links);
foreach ($all_links as $link) {
	$file_details = explode(',', $link);
		if(strlen($file_details[0]) > 1) {
			$content .= "<tr><td><strong>File name: </strong>" . $file_details[0] . &	quot;</td></tr>
					<tr><td style='padding-bottom:3rem;'><strong>Download link: </strong><a href='" . $file_details[1] . "' >Start Downloading</a></td></tr>"; 

<!-- If there was a Message sent with Email, inlcude it as well -->
if($emailMessage != "") {
	$content .= "<tr><td style='width:100%;'><strong>Sender message: </strong>" . $emailMessage . "</td></tr>";

<!-- Include closing HTML Tags -->
$content .= "</table>
		<h2 style='color:#0e2e40;font-family: Arial, Helvetica, sans-serif;text-align:center;font-weight:600; font-size:14px;'>Thank you for using our service</h2>

Example of how sent emials look like in Gmail:

Frontend Layout Configuration

Client side code uses only index.php file in the root directory to display the frontend.

Design Change:

To change the styles and functions of frontend you can customize following files as you prefer:
  • CSS
    • admin/assets/client/css/styles.css
  • JS
    • admin/assets/client/js/custom.css

Frontend Content Change:

Title, description and copyright information can be changed via Admin Panel under Frontend Layout tab.

Upload Configuration

Although Amazon S3 can potentially store unlimited number of files, your browser's parallel upload capability might be limited. The main limitation could be exceeding your stack with multipart chunk uploads.

S3 Multipart Upload Restrictions:

  • Maximum uploaded object size can be: 5TB
  • Maximum number of parts(file chunks) per upload: 10000. Important: It is strongly recommended to use bigger chunks for large files to avoid stack
  • Part size must be between 5MB and 5GB. There is no size limit on the last part of your multipart upload.
  • Maximum private signed link duration is: 7 Days

Default Settings Change:

You can change all default upload parameters and settings via Admin Panel under Upload Settings tab. Default change takes effect immediately and user will see them upon page refresh.

Accepted File Types has a special format that must be followed:
  • ['image/png', 'image/jpeg', ...] - Exact file types
  • ['image/*', 'audio/*', ...] - Grouped by file type category
  • [] - All file typess

Initial Release v1.0.0

Released on 30th October, 2020