コード例 #1
0
ファイル: UploadFileManager.php プロジェクト: Maxlander/shixi
 public function copyFile($uploadedFileInfo, $fileID)
 {
     if (!SJB_UploadFileManager::doesFileExistByID($fileID)) {
         list($fileName, $savedFileName) = SJB_UploadFileManager::getArrayOfFileNames($uploadedFileInfo['file_name']);
         $uploadFileDirectory = SJB_System::getSystemSettings('UPLOAD_FILES_DIRECTORY');
         if (copy($uploadFileDirectory . '/' . $uploadedFileInfo['file_group'] . '/' . $uploadedFileInfo['saved_file_name'], $fileName)) {
             if ($uploadedFileInfo['file_group'] == 'video') {
                 $baseName = substr($savedFileName, 0, strrpos($savedFileName, '.'));
                 $img = $uploadFileDirectory . '/' . $uploadedFileInfo['file_group'] . '/' . $baseName . '.png';
                 $uploadManager = new SJB_UploadVideoFileType($uploadedFileInfo);
                 $uploadManager->grab_image($fileName, $img, '00:00:03', 'png', 320, 240);
             }
             if (!empty($uploadedFileInfo['sid'])) {
                 unset($uploadedFileInfo['sid']);
             }
             $uploadedFileInfo['id'] = $fileID;
             $uploadedFileInfo['saved_file_name'] = $savedFileName;
             $uploadedFileFields = array_filter(array_keys($uploadedFileInfo), 'is_string');
             $keys = "`" . implode("`,`", $uploadedFileFields) . "`";
             $info = "'" . implode("','", array_values(array_intersect_key($uploadedFileInfo, array_flip($uploadedFileFields)))) . "'";
             SJB_DB::query("INSERT INTO `uploaded_files` (" . $keys . ") VALUES (" . $info . ")");
         }
     }
 }