2017-09-16 19 views
0

私のサイトにファイルをアップロードするためのスクリプトがあります。それは素晴らしいですが、今私は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.iniopen_basedirを設定しませんでしたが、動作しませんでした。 phpinfo()と表示されても、その設定には一連のパスが表示されます。私はgrepしようとしましたopen_basedirがサーバー上に存在します。実際には、ファイルはphp.iniなので、phpinfo()に報告されているもの以外は変更する必要はありません。

答えて

0

私はそれを修正しました。何らかの理由で、grepがbasedir文字列を含むすべてのファイルを返していない。 /etc/php/7.0/fpm/pool.d/web8.confとパスを追加します:私は、特定のサイトのためのphp-FPMファイルを編集する必要がありました

/usr/bin/ffmpeg:/usr/bin/ffprobe

php_admin_value[open_basedir]ディレクティブに。その後、systemctl reload php7.0-fpm.serviceと完了しました。

関連する問題