0

我无法使用浏览器在 sdk 2.* 上执行此代码;

<?php
header('Content-type: text/plain; charset = utf-8');
require 'aws-autoloader.php';
use Aws\S3\S3Client;
require 's3_config.php'; // credentials vs.
$time_start = microtime(true);
#----------------------------------------------------#
$bucket = time()."unique_bucket_id";
  echo "Creating bucket named {$bucket}\n";
  $result = $client->createBucket(array(
  'Bucket' => $bucket
  ));
  // Wait until the bucket is created
  $client->waitUntilBucketExists(array('Bucket' => $bucket));

  echo "Created {$bucket}\n";
#-------------------------------------------------------#
$time = microtime(true)-$time_start;
echo PHP_EOL.PHP_EOL.$time.PHP_EOL;

但它在终端中清晰地工作。使用浏览器应该怎么做?(当我根据php sdk 1.6.2更改代码时,它可以同时在终端和浏览器上工作。我的意思是没有权限问题。)

4

1 回答 1

1

When you run from the cli, the home directory is set in the environment as the home directory of the user you are logged in. /home/your_username

On web, it's set another home directory, usually the web service's one. You can check by running echo getenv('HOME'); both in cli and web and the create the .aws/credentials file in the according directories.

于 2015-03-05T14:40:24.480 回答