我正在尝试将视频上传到Wistia。该视频已成功上传。但问题是,当我播放显示错误消息的视频时,如编码失败错误。这里我已经分享了我的代码供参考。
public function video_upload($filePath,$fileName){
$tempuploaddir = "img/temp/";
if (!file_exists($tempuploaddir)) {
mkdir($tempuploaddir, 0777, true);
chmod($tempuploaddir, 0777);
}
move_uploaded_file($filePath,$loc=$tempuploaddir.$fileName);
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? 'https' : 'http';
$serverURL = $protocol . '://' . $_SERVER['HTTP_HOST'] . $this->request->webroot;
$urlPath= $serverURL.'webroot/'.$loc;
$data = array(
'api_password' => '0fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXf5',
'url' => $urlPath
);
$chss = curl_init('https://upload.wistia.com');
curl_setopt_array($chss, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POSTFIELDS => http_build_query($data)
));
$KReresponse = curl_exec($chss);
$KReresponseData = json_decode($KReresponse, TRUE);
unlink($tempuploaddir.$fileName);
echo("Response:");
print_r($KReresponseData);
}
答案 0 :(得分:1)
是的,最后我解决了我的错误。通过使用cURL文件对象方法。
// Create a cURL handle
$ch = curl_init('http://example.com/upload.php');
// Create a CURLFile object
$cfile = new CURLFile('cats.jpg','image/jpeg','test_name');
// Assign POST data
$data = array('test_file' => $cfile);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Execute the handle
curl_exec($ch);