Last active
January 7, 2025 21:32
-
-
Save Wysie/03934b6a79a715772abd to your computer and use it in GitHub Desktop.
Revisions
-
Wysie revised this gist
Sep 28, 2014 . No changes.There are no files selected for viewing
-
Wysie revised this gist
Sep 28, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ //Using S3.php from https://github.com/tpyo/amazon-s3-php-class. Place it in includes/helpers //Replaces Sendy's includes/create/upload.php <?php @@ -17,8 +17,8 @@ if(in_array($extension, $allowed)) { $awsAccessKey = get_app_info('s3_key'); $awsSecretKey = get_app_info('s3_secret'); $bucketName = 'BUCKETNAME'; //Change accordingly $endpoint = 's3-ap-southeast-1.amazonaws.com'; //Change accordingly $s3 = new S3($awsAccessKey, $awsSecretKey, false, $endpoint); $s3Filename = $time.baseName($fileName); -
Wysie created this gist
Sep 28, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ //Using S3.php from https://github.com/tpyo/amazon-s3-php-class //Replaces Sendy's includes/create/upload.php <?php include('../functions.php'); include('../login/auth.php'); require_once('../helpers/S3.php'); //Init $file = $_FILES['file']['tmp_name']; $fileName = $_FILES['file']['name']; $extension_explode = explode('.', $fileName); $extension = $extension_explode[count($extension_explode)-1]; $time = time(); $allowed = array("jpeg", "jpg", "gif", "png"); if(in_array($extension, $allowed)) { $awsAccessKey = get_app_info('s3_key'); $awsSecretKey = get_app_info('s3_secret'); $bucketName = 'co.mailworthy.media'; $endpoint = 's3-ap-southeast-1.amazonaws.com'; $s3 = new S3($awsAccessKey, $awsSecretKey, false, $endpoint); $s3Filename = $time.baseName($fileName); if ($s3 -> putObject($s3->inputFile($file), $bucketName, $s3Filename, S3::ACL_PUBLIC_READ)) { $array = array( 'filelink' => 'http://'.$endpoint.'/'.$bucketName.'/'.$s3Filename ); echo stripslashes(json_encode($array)); } else exit; } else exit; ?>