开发者

How to upload video files on cdn server?

I am trying to upload video on cdn server(hwcdn.net server) through api, but getting the following error . " 0470 Invalid file name (A-Z,a-z,0-9,-,_,',.) "


//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");
  }
  retur开发者_如何学JAVAn $response;
}


I think this is wrong :

$directory="/folder path/"; 

The space is not allowed in hwcdn paths.


The answer is in the error: the filename contains illegal chars, you have to sanitize it removing everything that is not A-Z,a-z,0-9,-,_,',..

You can use preg_replace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜