Files
Chamilo/plugin/jcapture/upload.php
T
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

63 lines
1.3 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../../main/inc/global.inc.php';
api_protect_course_script();
$plugin = new AppPlugin();
$pluginList = $plugin->getInstalledPlugins();
$capturePluginInstalled = in_array('jcapture', $pluginList);
if (!$capturePluginInstalled) {
exit;
}
if (!isset($_FILES['Filedata'])) {
exit;
}
$courseInfo = api_get_course_info();
$folderName = 'captures';
$documentId = DocumentManager::get_document_id($courseInfo, '/'.$folderName);
$path = null;
if (empty($documentId)) {
$course_dir = $courseInfo['path'].'/document';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$dir = $sys_course_path.$course_dir;
$createdDir = create_unexisting_directory(
$courseInfo,
api_get_user_id(),
api_get_session_id(),
null,
null,
$dir,
'/'.$folderName,
$folderName
);
if ($createdDir) {
$path = '/'.$folderName;
}
} else {
$data = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
$path = $data['path'];
}
if (empty($path)) {
exit;
}
$files = [
'file' => $_FILES['Filedata'],
];
DocumentManager::upload_document(
$files,
$path,
$_FILES['Filedata']['name'],
null,
false,
'rename',
false,
true
);