Skip to content

Instantly share code, notes, and snippets.

Created Oct 6, 2021
What would you like to do?
simple s3 php script upload
include 'S3.php';
define('S3_ENDPOINT', '');
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