这是我用PHP在我的rackspace账户中上传图片的简单代码:
<?php
$api_username = 'lolcat';
$api_key = 'sexyapi';
require 'cloudfiles.php';
$auth = new CF_Authentication($api_username, $api_key);
$auth->authenticate();
$connection = new CF_Connection($auth);
$images = $connection->create_container("pitch");
$url = $images->make_public();
echo 'The url is '.$url;
$file = 'sherlock.jpg';
$img = $images->create_object($file);
$img->load_from_filename($file)
?>而且每次它都会给出不同的错误。比如:“严格的标准:在1969年的C:\wamp\www\cloudfiles.php中,只有变量应该通过引用传递。”
“致命错误:在1249行的C:\wamp\www\cloudfiles_http.php中超过了30秒的最大执行时间”
A sample of errors (imgur image)
请帮帮忙,我已经试了2个小时了。
发布于 2014-01-17 12:40:11
Php-cloudfiles绑定已弃用。我建议你试一试php-opencloud。我应该不难移植你的代码。下面是一个简单的例子:
<?php
require 'vendor/autoload.php';
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => 'foo',
'apiKey' => 'bar'
));
$service = $client->objectStoreService('cloudFiles', 'DFW');
$container = $service->createContainer('pitch');
$container->enableCdn();
$cdn = $container->getCdn();
//Print "Container SSL URL: " . serialize($cdn);
$files = array(
array(
'name' => 'file_1.txt',
'body' => fopen('files/file_1.txt', 'r+')
)
);
$container->uploadObjects($files);你可以在https://github.com/rackspace/php-opencloud/blob/master/docs/getting-started.md上找到php-opencloud文档。
https://stackoverflow.com/questions/21159016
复制相似问题