Sean Sean - 25 days ago 15
PHP Question

Using PHP to upload to Amazon S3

I've spent the last few hours following tutorials for implementing file uploads to Amazon S3 using php. I uploaded the most recent version of Donovan Schönknecht's S3 class to my server (as S3.php) and I am trying to use the following code to test upload capability. I know this code will work because I've seen numerous examples in action.

<?php

require('S3.php');

$s3 = new S3('KEY', 'SECRET KEY');

//insert into s3
$new_name = time() . '.txt';

S3::putObject(
'upload-me.txt',
'bucketName',
$new_name,
S3::ACL_PUBLIC_READ,
array(),
array(),
S3::STORAGE_CLASS_RRS

);

?>


I get an error 500 server error when I attempt to load this page. Additionally, every other reputable tutorial of this nature has given me the same error 500.

I verified that my key and secret key are valid by connecting to S3 with Cyberduck.

Does anyone have a clue as to what I could be doing incorrectly?

Thanks,

Sean

Answer

As it turns out, I was missing the cURL extension for PHP and this was causing an issue as the S3 class I was using required the use of cURL. All is working now.

Comments