ラックスペースのcdnアカウントに画像をアップロードする次のコードがあります。
error_reporting(E_ALL);
ini_set('display_errors', 1);
// include the API
require("cloudfiles.php") ;
// cloud info
$username = ''; // username
$key ='' ; // api key
$container = ''; // container name
ob_start();
$localfile = $_FILES['media']['tmp_name'];
$filename = $_FILES['media']['name'];
ob_flush();
// Connect to Rackspace
$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);
// Get the container we want to use
$container = $conn->create_container($container);
// store file information
ob_flush();
// upload file to Rackspace
$object = $container->create_object($filename);
$object->load_from_filename($localfile);
$uri = $container->make_public();
//print "Your URL is: " . $object->public_uri();
$imagePageUrl = $object->public_uri();
//echo '<mediaurl>' . $imagePageUrl . '</mediaurl>';
ob_end_flush();
//echo '<mediaurl>' . $imagePageUrl . '</mediaurl>';
echo '<mediaurl>http://url.com/'.$filename.'</mediaurl>';
したがって、画像、たとえばimage.jpgをアップロードするたびに、コンテナ内の前のimage.jpgが上書きされます。それを防ぎたい。ファイル名が同じでも、ファイル名をランダムな名前、文字に変換してアップロードする方法はありますか?
plzを助けます。