CodeIgniter AWS S3 Integration Library

CodeIgniter AWS S3 Integration Library


CodeIgniter AWS S3 Integration is a CodeIgniter Library which provides an easy way to integrate AWS S3 in a CodeIgniter project.

Using this library you can use the S3(Simple Storage Service by Amazon) bucket as a storage for user uploaded files in your Codeigniter project. It was never easy to use S3 as a storage media for your Codeigniter Project before this library, It will hardly take 5 minutes in integration. It will simply save you several hours of time for the integration.

Note: In order to use S3 as a storage you do not need to host your project on AWS. You can use S3 service from any hosting server, even from your local Server too.
Looking forward to use S3 in your existing CodeIgniter system to scale with low cost storage?
If yes than It’s easiest way to achieve that!


  1. Easy configuration.
  2. Extended Codeigniter upload library so things are easy to use and understand, keeping you in context
  3. Use of single function to use S3 as Storage instead of web-server for uploaded files.
  4. Use of single function to manually upload any web-server file from web-server to an S3 bucket.
  5. Option to feed Bucket name, Region, File ACL and many more dynamically
  6. Use of the original AWS SDK library to connect with the S3 service.
  7. Copy a S3 file in same Bucket.
  8. Create a S3 Bucket in AWS account.
  9. Create Pre-signed url for sharing temp download link for any file in S3 bucket
  10. Allow direct browser upload, without uploading to server first. A efficient approach for big size files.

See how easy it is to use, with sample codes.

Using do_upload_s3() function, the uploaded file will store on same relative location in an S3 Bucket instead of web-server.

//Normal code to upload a file on web-server
//Change to

Using s3_site_url() function, File will be referenced from same relative location from S3 Bucket instead of web-server.

//Normal code to refer a file on web-server
<a href="<?php echo site_url("uploads/myphoto.jpg"); ?>">Download</a>
//Change to
<a href="<?php echo s3_site_url("uploads/myphoto.jpg"); ?>">Download</a>

Upload a file manually from the web-server to an S3 bucket

//Upload myphoto.jpg file to S3 Bucket.

Copy a S3 file from one Bucket to another or in same Bucket

//Copy S3 File

To create a S3 Bucket in your AWS account

//Create a S3 Bucket
$bucket_name = "cis3demotestingbucket";
$flag = $this->cis3integration_lib->create_bucket($bucket_name);

To create a pre-signed url of a file in S3 bucket

//Create a pre-signed url
$presignedUrl = $this->cis3integration_lib->get_presigned_url("myfile.jpg",10);    
//where 10 is the lifetime of pre-signed url in seconds

To do direct upload to s3 from browser

<!-- Start of the JavaScript -->
<!-- Load jQuery & jQuery UI (Needed for the FileUpload Plugin) -->
<script src=""></script>
<script src=""></script>

<script src=""></script>
<!--Load Javascript library-->
<script src="<?php echo site_url("js/cis3integration_lib.js");?>"></script>      

    var config = {
        // Place any uploads within the descending folders
        // so ['test1', 'test2'] would become /test1/test2/filename
        //var folders = ['uploads'];        
        allowed_types: ['jpeg', 'jpg', 'png', 'gif', 'bmp', 'pdf', 'doc', 'docs', 'zip'],
    function callFileValidation(fileField){
        return ciS3Integration.doFileValidation(fileField);                  
//Refer the source code for more detail.    


Find here the detail documentation: Documentation

Free Support:

We are willing to help and provide support you through any problems you may have, or and features/suggestions that you want to implement. Just send me an email or leave a comment.


19 Nov, 2017: What’s new
# Create Pre-signed URL for temp download link.
# Browser Upload: Upload a file directly from browser to S3 bucket without uploading to server first. An efficient approachh for big size files.
# Create a S3 Bucket in AWS account.
# Added bootstrap support in demo

26 March, 2016: What’s new
# Codeigniter 3.x demo included, Now use the latest version of Codeigniter.
# Latest AWS SDK for PHP Version 3 implemented
# Set Bucket name dynamically
# Option to specify Region name
# Option to choose File ACL
# Option to rename or not the file during upload

13 Nov, 2013: What’s new
# Delete a File from S3 Bucket.
# Copy a File from one Bucket to another or in same Bucket.
# Create a S3 Bucket in AWS account.
# File can be upload on root of S3 Bucket without any folder.
# Maintaied upload file mime type so Images do not get download when viewing on AWS URL.
# Better quality and maintained code, did changes in structure slightly for improvement. It will be easy to understand.

Note: AWS/S3 and Codeigniter are the Trademarks of their respective owners.


Author Image