Using Aws s3 api with php for image uploading

Aws s3 is handy tool for storing and managing large image base for work. Following is the code skeleton for this purpose.

require $_SERVER['DOCUMENT_ROOT'].'/assets/s3-upload/vendor/autoload.php';

// s3 image upload
///////////////////
if(!empty($_FILES)){
	$s3 = new Aws\S3\S3Client([
		'region'  => $this->config->item('s3_region'),
		'version' => 'latest',
		'credentials' => [
			'key'    => $this->config->item('s3_key'),
			'secret' => $this->config->item('s3_secret'),
		]
	]);				
	$i = 0;
	foreach( $_FILES['fusion-image']['tmp_name'] as $tempImage ){	
		
		try {
			$key = $_FILES["fusion-image"]["name"][$i];
			//echo $_SERVER['DOCUMENT_ROOT'].'s3-upload/fusions-code-folder.png'; exit;
			$result = $s3->putObject([
				'Bucket' => $this->config->item('s3_bucket'),
				'Key'    => $key,
				'Body'   => $_FILES["fusion-image"]["name"][$i],
				'SourceFile' => $tempImage //-- use this if you want to upload a file from a local location
			]);   
			
			$saveData = array(
				'fusion_id' => $fusionId,
				'name' => $_FILES["fusion-image"]["name"][$i],
				'created' => time(),
				'modified' => time(),
			);
			$this->GeneralModel->updateRow($saveData,null,'fusion_images');
			$showImageTab = '?tab=images'; 
			$i++;    
		
		}
		//catch exception
		catch(Exception $e) {
			$messge = array('message' => 'Image Not uploaded','class' => 'alert alert-danger');
		}                                      
	}
}