Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
S3
<form action="" enctype="multipart/form-data" method="post">
<h3>Upload arquivo</h3>
<input name="file" type="file" />
<input type="submit" value="Upload" />
</form>
<?php
include_once("S3.php");
if($_SERVER['REQUEST_METHOD'] == "POST"){
$bucket="seu_bucket";
$awsAccessKey="sua_access_key";
$awsSecretKey="sua_scret_key";
$s3 = new S3($awsAccessKey, $awsSecretKey);
$tmp_name=$_FILES['file']['tmp_name'];
$nome_arquivo=$_FILES['file']['name'];
if($s3->putObjectFile($tmp_name, $bucket , $nome_arquivo, S3::ACL_PUBLIC_READ) ){
$s3file='https://'.$bucket.'.s3.amazonaws.com/'.$nome_arquivo;
echo 'S3 File URL:'.$s3file;
}
}
@carlo5romero

This comment has been minimized.

Copy link

commented May 9, 2018

GREAT!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.