这是我的密码
<?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>
当我试图上传一张图片时,我遇到了这个错误
在“”上执行“PutObject”时出错
http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png
“AWS HTTP错误:客户端错误:
PUT http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png
结果是
403 Forbidden
响应:AccessDeniedAccessDenied07E90B(截断…)访问被拒绝(客户端):访问被拒绝-访问被拒绝访问被拒绝07E90B12D3A0DBA15KSO11CFV57KBQ3SBO9DHHTZB4XT56KS64BTFHYKG6A0CIXRQWIPSAK3TU4I+XCIyBNU3Dics=
有什么想法吗?我也给了用户完全的权限。