2011-06-07 186 views
0

我试图通过api在cdn服务器(hwcdn.net服务器)上传视频,但得到以下错误。 “0470无效的文件名(包括AZ,az,0-9, - ,_,',.)如何在cdn服务器上上传视频文件?

 

//PHP example code for calling an action: 
$action = "UF"; //get system info 
$user = "xxxxxx"; //my StrikeTracker user name 
$pass = "xxxxxx"; //my StrikeTracker password 
$apiKey ="xxxxxxxxxxxxxxxxxxxx"; //my API Key 
$md5pass = md5($pass); 
$queryString = "action=$action&user=$user&key=$apiKey&password=$md5pass"; 
$token =md5($queryString); 
$directory="/folder path/"; 
$Filedata="testingvideo.flv"; 
echo $apiQuery = "action=$action&user=$user&token=$token&directory=$directory&Filedata=$Filedata"; 
$host="http://st-api.hwcdn.net/index.php"; 

echo do_post_request($host,$apiQuery); 

function do_post_request($url, $data, $optional_headers = null) 
{ 
    $params = array('http' => array(
       'method' => 'POST', 
       'content' => $data 
      )); 
    if ($optional_headers !== null) { 
    $params['http']['header'] = $optional_headers; 
    } 

    $ctx = stream_context_create($params); 
    $fp = @fopen($url, 'rb', false, $ctx); 
    if (!$fp) { 
    throw new Exception("Problem with $url, $php_errormsg"); 
    } 
    $response = @stream_get_contents($fp); 
    if ($response === false) { 
    throw new Exception("Problem reading data from $url, $php_errormsg"); 
    } 
    return $response; 
} 

回答

0

我认为这是错误的:

$directory="/folder path/"; 

的空间hwcdn路径是不允许的。

0

答案是错误:文件名中包含非法字符,你必须消毒它删除所有不是A-Z,a-z,0-9,-,_,',.。可以使用preg_replace

+0

我的文件名是testingvideo.flv,这个文件名有什么问题。 – 2011-06-07 11:33:54