1
首先,讓我說,我已經有一段艱難的時間來提問,這些問題是以Stack Overflow社區感到滿意的方式制定的。所以,我希望這個問題是可以接受的 - 我只是尋找一些我在任何地方都找不到的幫助。謝謝!當文件存在時PHP?
我正在製作一個應用程序,允許用戶通過Web表單自定義視頻,點擊提交,JSON攝入視頻軟件,該軟件會自動在我們的服務器上呈現項目,然後通過FTP自動上傳到http://www.example.com/video-renders/
。
假設用戶在表單提交時指定的文件名是video.mp4
。
當該用戶提交渲染/上傳項目時,是否可以觸發該PHP腳本'012'觀看video-renders
目錄中的filename = video.mp4
並執行腳本將視頻上傳到Wistia?
這裏是我的PHP,成功地上傳文件(URL)來Wistia:
<?php
$api_request_url = 'https://upload.wistia.com';
$method_name = 'POST';
$api_request_parameters = array(
'api_password' => '<<my_api_password>>',
'url' => 'http://www.example.com/video-renders/'.$_POST['video-name'],
'project_id' => $_POST['user-project-id']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
if ($method_name == 'DELETE')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($api_request_parameters));
}
if ($method_name == 'GET')
{
$api_request_url .= '?' . http_build_query($api_request_parameters);
}
if ($method_name == 'POST')
{
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($api_request_parameters));
}
if ($method_name == 'PUT')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($api_request_parameters));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_URL, $api_request_url);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$api_response = curl_exec($ch);
$api_response_info = curl_getinfo($ch);
curl_close($ch);
$api_response_header = trim(substr($api_response, 0, $api_response_info['header_size']));
$api_response_body = substr($api_response, $api_response_info['header_size']);
// Response HTTP Status Code
echo $api_response_info['http_code'];
// Response Header
echo $api_response_header;
// Response Body
echo $api_response_body;
?>
謝謝,但#2不可用,因爲我的渲染軟件(Adobe Media Encoder)具有內置的FTP功能。如何循環PHP腳本直到「成功」? – user1661677