Skip to content

Instantly share code, notes, and snippets.

@23Pstars
Created October 6, 2021 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 23Pstars/eeb2aa969efc4a8be015b87a643d3e9b to your computer and use it in GitHub Desktop.
Save 23Pstars/eeb2aa969efc4a8be015b87a643d3e9b to your computer and use it in GitHub Desktop.
simple s3 php script upload
<?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