A lot of these answers are old and looking at Orbit's answer I think there must have been many changes to the API since then. And since ftrotter already explained about trying to upload directly, I will show you an updated version (PHP 5.3 style) of how to send the files from the PHP tmp directory.
First we'll assume you already installed the API using composer.
First you'll need to include their autoloader and then add the use
namespace.
require 'vendor/autoload.php';
use OpenCloud\Rackspace as Rackspace;
Then you simply setup the client instance
// first setup the client using your portal username and API key
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => 'YOUR-USERNAME',
'apiKey' => 'YOUR-API-KEY'
));
$region = 'DFW'; // can be ORD or various others and must be set
// now get the container
$container = $client->objectStoreService('cloudFiles', $region)
->getContainer('YOUR-CONTAINER');
Now that you have your container you can simply setup your array of files and upload them. Here's a quick and dirty way:
if (isset($_FILES)) {
$files = array();
foreach ($_FILES as $file) {
if (0 === $file['error']) {
$files[] = array(
'name' => $file['name'],
'path' => $file['tmp_name']
);
}
}
if (count($files)) {
// upload files to Rackspace Cloud Files container
$result = $container->uploadObjects($files);
}
}
Now you your files will keep their existing names when they end up in the container, and you can get the public URL path for your container right from within the Rackspace Cloud portal.