$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, $file['name'], '', // comment $unzip, $defaultFileExistsOption, false, false, 'files' ); $json = array(); if (!empty($result) && is_array($result)) { $json['name'] = Display::url( api_htmlentities($result['title']), api_htmlentities($result['url']), array('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['url'] = ''; $json['error'] = get_lang('Error'); } $resultList[] = $json; } echo json_encode(['files' => $resultList]); } exit; break; case 'document_preview': $course_info = api_get_course_info_by_id($_REQUEST['course_id']); if (!empty($course_info) && is_array($course_info)) { echo DocumentManager::get_document_preview( $course_info, 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;