这是我的代码
<?php
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
error_reporting(0);
function pre($arr){
echo '<pre>';print_r($arr);echo '</pre>';
}
if($_FILES['image']['name'] != ''){
require 'aws/aws-autoloader.php';
$client = S3Client::factory([
'version' => 'latest',
'region' => 'eu-west-2',
'credentials' => [
'key' => "XXXXXXX",
'secret' => "XXXXXXX"
],
'scheme' => 'http'
]);
try {
$insert = $client->putObject([
'Bucket' =>'xxx',
'Key' => $_FILES["image"]["name"],
'SourceFile' => $_FILES["image"]["tmp_name"],
'ACL' => 'public-read'
]);
} catch (S3Exception $e) {
// Catch an S3 specific exception.
echo $e->getMessage();
}
die;
}
?>
<!DOCTYPE html>
<html>
<body>
<form action="aws.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="image" id="image">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
当我尝试上传图片时,出现此错误
在“ http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png”上执行“ PutObject”时出错; AWS HTTP错误:客户端错误:
PUT http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png
导致了403 Forbidden
响应:AccessDeniedAccess Denied07E90B(被截断了...)AccessDenied(客户端):Access Denied-AccessDeniedAccess Denied07E90B12D3A0DBA15kSo11cfv57kBQ3sBo9dHHtZb4XtCy3B
关于什么可能是问题的任何想法?我也已向用户授予FullS3Permission。