2017-09-16 35 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> 

我已通過的ffmpeg庫ffprobe所以它知道它是絕對路徑。我在四處搜尋,有些人說這是因爲lib無法訪問帶有上傳文件的tmp目錄。在任何情況下,我一直在試圖禁用open_basedir或至少增加我需要它來得到這個工作的路徑。

我想在我的php.ini設置open_basedir到沒有,但沒有奏效。當我查看phpinfo()時,它仍然列出了該設置的一堆路徑。我試圖grep open_basedir存在於服務器上。事實上,它的php.ini文件,我應該不需要修改任何其他一個比phpinfo()報道。

回答

0

我固定它。出於某種原因,grep沒有返回包含basedir字符串的所有文件。我不得不修改爲特定站點的PHP-FPM文件:/etc/php/7.0/fpm/pool.d/web8.conf和追加的路徑:

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

php_admin_value[open_basedir]指令。然後systemctl reload php7.0-fpm.service並完成。