我正在尝试通过api在cdn服务器(hwcdn.net服务器)上传视频,但收到以下错误。 “ 0470文件名无效(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"); } return $response; }
答案 0 :(得分:0)
答案在错误中:文件名包含非法字符,您必须清除它,删除所有不是A-Z,a-z,0-9,-,_,',.
的内容。
您可以使用preg_replace
。
答案 1 :(得分:0)
我认为这是错误的:
$directory="/folder path/";
hwcdn
路径中不允许使用空格。