seems to work fine More than likely the issue that you are running into is with the permissions that are set on the s3 bucket and not your code. You either need to change the permissions on that bucket it self or you have to set up a policy that aws user that is trying trying to delete the file.
may help you . In the case you are describing, "photos" is the bucket. S3 does not have sub-buckets or directories. Directories are simulated by using slashes in the object key. "thumbs/file.jpg" is an object key and "thumbs/" would be considered a key prefix. Dagon's examples are good and use the older version 1.x of the AWS SDK for PHP. However, you can do this more easily with the newest 2.4.x version AWS SDK for PHP which includes a helper method for deleting multiple objects.
// Include the SDK. This line depends on your installation method.
$s3 = S3Client::factory(array(
'key' => 'your-aws-access-key',
'secret' => 'your-aws-secret-key',
// Delete the objects in the "photos" bucket with the a prefix of "thumbs/"
help you fix your problem You can go into S3 select a single file and delete it. Afterwards you can upload a new file. Old console: Select the file in S3 and click Actions and then click delete. New console: Select the file in S3 and click More and than click delete.