我正在尝试将视频上传到Wistia。视频在我的本地服务器上成功上传。但是,当我转移到开发服务器时,视频没有上传它显示错误,例如"内部服务器错误"。
我收到错误消息:
Array
(
[0] => HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Server: nginx/1.4.6 (Ubuntu)
Date: Mon, 07 Mar 2016 10:07:57 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 30
Status: 500 Internal Server Error
Access-Control-Allow-Origin: *
Set-Cookie: __bakery_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiRTYxN2JjZjE2OGI0YzJmYTE3MDU5%0AZTU0MWNmNWZlNjVkNDQzNzhmOWYwOGNlMWE0YTliNTQyMDNhNDg2ZGY3YjYG%0AOwBG%0A--4d80faca0eafbbec57b24297ed762aa798486fde; path=/; HttpOnly
Set-Cookie: rack.session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiRTYxN2JjZjE2OGI0YzJmYTE3MDU5%0AZTU0MWNmNWZlNjVkNDQzNzhmOWYwOGNlMWE0YTliNTQyMDNhNDg2ZGY3YjYG%0AOwBG%0A; path=/; HttpOnly
X-Served-By: bakery-breadroute-roll,bakery-prime-changeling
Internal Server Error
)
我的视频上传代码:
<?php
if ($_POST['submit']) {
$filePath = $_FILES['fileUploaded']['tmp_name'];
$data = array(
'api_password' => '0fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5',
'file' => '@'.realpath($filePath),
'description' => 'This is a test video',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, "https://upload.wistia.com" );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
}
?>
<form name="upload-form" method="POST" enctype="multipart/form-data">
<input type="file" name="fileUploaded">
<input type="submit" name="submit" value="Upload">
</form>
任何人都帮助我解决这个问题。
答案 0 :(得分:2)
是的,最后我解决了我的错误。通过使用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);