私のサイトにファイルをアップロードするためのスクリプトがあります。それは素晴らしいですが、今私は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>
私はそれがどこにあるので、それを知っているffprobeする絶対パスをffmpegのライブラリに合格しています。私は周りを捜していて、アップロードされたファイルでlibがtmpディレクトリにアクセスできないため、これは何人かの人が言っていました。どちらの場合でも、私はopen_basedir
を無効にしようとしていました。少なくとも、これを動作させるために必要なパスを追加してください。
php.ini
にopen_basedir
を設定しませんでしたが、動作しませんでした。 phpinfo()
と表示されても、その設定には一連のパスが表示されます。私はgrepしようとしましたopen_basedir
がサーバー上に存在します。実際には、ファイルはphp.ini
なので、phpinfo()
に報告されているもの以外は変更する必要はありません。