我要上传使用给定的图像的Amazon S3
I need to upload a given image using Amazon S3
我有这个PHP:
<?
$uploaddir = 'images/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Data Uploaded Successfully";
} else {
echo "ERROR";
}
?>
但它给我这个错误:
but it gives me this error:
<?xml version="1.0" encoding="UTF-8" ?>
<Error>
<Code>MethodNotAllowe</Code>
<Message>The specified method is not allowed against this resource.</Message>
<ResourceType>OBJECT</ResourceType>
<Method>POST</Method>
....
<AllowedMethod>PUT</AllowedMethod>
....
</Error>
如何上传文件?
How can I upload a file?
正在使用 POST
的方法(这是PHP的默认值),以提交数据。大多数web应用的动词之间differenciate GET
, PUT
和 POST
(见动词 W3 RFC)。
You are using the POST
method (which is PHP defaults) to submit the data. Most webapplications differenciate between the verbs GET
, PUT
and POST
(see W3 RFC on Verbs).
S3要你使用&LT; AllowedMethod&GT; PUT&LT; / AllowedMethod&GT;
的方法。 move_uploaded_file是不是能够做到这一点。在您开始编写code做PUT请求,也许你应该看看一些的 PHP S3库的。
S3 wants you to use <AllowedMethod>PUT</AllowedMethod>
as the method. move_uploaded_file isn't able to do that. Before you start writing code for doing PUT requests, maybe you should take a look at some PHP S3 libs.