Created
October 6, 2021 08:03
-
-
Save 23Pstars/eeb2aa969efc4a8be015b87a643d3e9b to your computer and use it in GitHub Desktop.
simple s3 php script upload
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 characters
<?php | |
include 'S3.php'; | |
define('S3_ENDPOINT', 's3.amazonaws.com'); | |
define('S3_BUCKET', 'bucket'); | |
define('S3_DIR', 'path/to/dir'); | |
define('S3_KEY', '*****'); | |
define('S3_SECRET', '*****'); | |
// submitted form | |
$_stored_filename = 'file.txt'; | |
$_file_tmp_name = $_FILES['tmp_name']; | |
new S3(S3_KEY, S3_SECRET, false, S3_ENDPOINT); | |
S3::putObjectFile($_file_tmp_name, S3_BUCKET, S3_DIR . DS . $_stored_filename, S3::ACL_PUBLIC_READ); | |
$_uploaded_file = 'https://' . S3_ENDPOINT . DS . S3_BUCKET . DS . S3_DIR . DS . $_stored_filename; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment