我有上傳文件到我的網站的腳本。它的偉大工程,但現在我想提取使用ffmpeg/ffprobe library視頻文件的元數據。我的代碼:
if (!empty($_FILES)) {
$requestAr = requestCheck(['title', 'description']);
$assetName = randomString(11);
$assetSalt = randomString(3);
$bucket = "videos";
$fileTmpPath = $_FILES['qqfile']['tmp_name'];
$filenameOrig = $_FILES['qqfile']['name'];
$fileExtension = pathinfo($filenameOrig, PATHINFO_EXTENSION);
$assetFilename = $assetName . "_$assetSalt.$fileExtension";
$trustedExtensions = ['webm', 'mp4', 'ogg'];
if(array_search($fileExtension, $trustedExtensions) !== false) {
$ffprobe = FFMpeg\FFProbe::create([
'ffprobe.binaries' => '/usr/bin/ffprobe'
]);
$fileInfo = $ffprobe
->format($fileTmpPath) // extracts file informations
->get('duration'); // returns the duration property
print_r($fileInfo);
}
}
我風與此錯誤:
file_exists(): open_basedir restriction in effect. File(/usr/bin/ffprobe) is not within the allowed path(s): <lists all the directories in the open_basedir variable>
我已通過的ffmpeg庫ffprobe所以它知道它是絕對路徑。我在四處搜尋,有些人說這是因爲lib無法訪問帶有上傳文件的tmp目錄。在任何情況下,我一直在試圖禁用open_basedir
或至少增加我需要它來得到這個工作的路徑。
我想在我的php.ini
設置open_basedir
到沒有,但沒有奏效。當我查看phpinfo()
時,它仍然列出了該設置的一堆路徑。我試圖grep open_basedir
存在於服務器上。事實上,它的php.ini
文件,我應該不需要修改任何其他一個比phpinfo()
報道。