$array) { $counter = 0; foreach ($array as $data) { $fileList[$counter][$name] = $data; $counter++; } } $resultList = []; foreach ($fileList as $file) { $globalFile = []; $globalFile['files'] = $file; $result = DocumentManager::upload_document( $globalFile, $currentDirectory, '', '', // comment $unzip, $defaultFileExistsOption, false, false, 'files' ); $json = []; if (!empty($result) && is_array($result)) { $json['name'] = api_htmlentities($result['title']); $json['link'] = Display::url( api_htmlentities($result['title']), api_htmlentities($result['url']), ['target' => '_blank'] ); $json['url'] = $result['url']; $json['size'] = format_file_size($file['size']); $json['type'] = api_htmlentities($file['type']); $json['result'] = Display::return_icon( 'accept.png', get_lang('Uploaded') ); } else { $json['name'] = isset($file['name']) ? $file['name'] : get_lang('Unknown'); $json['url'] = ''; $json['error'] = get_lang('Error'); } $resultList[] = $json; } echo json_encode(['files' => $resultList]); } exit; break; case 'document_preview': $courseInfo = api_get_course_info_by_id($_REQUEST['course_id']); if (!empty($courseInfo) && is_array($courseInfo)) { echo DocumentManager::get_document_preview( $courseInfo, false, '_blank', $_REQUEST['session_id'] ); } break; case 'document_destination': //obtained the bootstrap-select selected value via ajax $dirValue = isset($_POST['dirValue']) ? $_POST['dirValue'] : null; echo Security::remove_XSS($dirValue); break; } exit;