Error when uploading image using Amazon S3

0 votes

I am getting an error when i try to upload an image using S3. Here's the code:

<?
$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 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>

What do i do?

Mar 25, 2019 in AWS by datageek
• 3,090 points
2,119 views

1 answer to this question.

0 votes

You are using the php's default method POST to submit the data. Most web applications differentiate between the verbs GETPUT and POST. 

Take a look at PHP libraries. 

answered Mar 25, 2019 by Archana
• 5,640 points

Related Questions In AWS

0 votes
1 answer

AWS Access Key error when uploading to S3

You can try getting creating a new ...READ MORE

answered Feb 6, 2019 in AWS by Priyaj
• 58,100 points
6,359 views
+1 vote
1 answer

Invalid hostname error when connecting to S3 using secret key

Hey, it works perfectly fine you just ...READ MORE

answered Oct 11, 2018 in AWS by Archana
• 4,170 points
4,361 views
+1 vote
2 answers
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,100 points
5,822 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,100 points
5,137 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,816 views
+1 vote
2 answers

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,640 points
54,288 views
0 votes
1 answer

Using Amazon S3 for the photo storage

Pre-generating different sizes and storing them in ...READ MORE

answered Oct 26, 2018 in AWS by Archana
• 5,640 points
1,001 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP