diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css
index e394196e03..d218e5e7f6 100644
--- a/app/Resources/public/css/base.css
+++ b/app/Resources/public/css/base.css
@@ -5399,7 +5399,7 @@ div#chat-remote-video video {
width: 420px;
}
.tab-wrapper .tab-content{
- padding: 25px;
+ padding: 25px 0px 25px 0px;
}
.description-upload{
margin-bottom: 10px;
diff --git a/main/document/upload.php b/main/document/upload.php
index 4269d90cbf..4c6adf74d0 100755
--- a/main/document/upload.php
+++ b/main/document/upload.php
@@ -315,7 +315,7 @@ if ($is_certificate_mode) {
// Link to create a folder
-echo $toolbar = Display::toolbarAction('toolbar-upload', array( 0 => $actions), 1);
+echo $toolbar = Display::toolbarAction('toolbar-upload', array(0 => $actions), 1);
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) {
diff --git a/main/inc/ajax/document.ajax.php b/main/inc/ajax/document.ajax.php
index 524a1944d2..f99780e785 100755
--- a/main/inc/ajax/document.ajax.php
+++ b/main/inc/ajax/document.ajax.php
@@ -26,13 +26,29 @@ switch ($action) {
exit;
}
- $fileExistsOption = api_get_setting('document_if_file_exists_option');
- $defaultFileExistsOption = 'rename';
- if (!empty($fileExistsOption)) {
- $defaultFileExistsOption = $fileExistsOption;
+ $directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0;
+ $currentDirectory = '';
+ if (empty($directoryParentId)) {
+ $currentDirectory = isset($_REQUEST['curdirpath']) ? $_REQUEST['curdirpath'] : '';
+ } else {
+ $documentData = DocumentManager::get_document_data_by_id($directoryParentId, api_get_course_id());
+ if ($documentData) {
+ $currentDirectory = $documentData['path'];
+ }
}
- //$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : $defaultFileExistsOption;
+ $ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : '';
+ $unzip = isset($_POST['unzip']) ? 1 : 0;
+
+ if (empty($ifExists)) {
+ $fileExistsOption = api_get_setting('document_if_file_exists_option');
+ $defaultFileExistsOption = 'rename';
+ if (!empty($fileExistsOption)) {
+ $defaultFileExistsOption = $fileExistsOption;
+ }
+ } else {
+ $defaultFileExistsOption = $ifExists;
+ }
if (!empty($_FILES)) {
$files = $_FILES['files'];
@@ -51,10 +67,10 @@ switch ($action) {
$globalFile['files'] = $file;
$result = DocumentManager::upload_document(
$globalFile,
- $_REQUEST['curdirpath'],
+ $currentDirectory,
$file['name'],
'', // comment
- 0,
+ $unzip,
$defaultFileExistsOption,
false,
false,
diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php
index f04a4590cb..0b37bd1c18 100755
--- a/main/inc/lib/document.lib.php
+++ b/main/inc/lib/document.lib.php
@@ -2789,6 +2789,8 @@ class DocumentManager
* @param string $if_exists overwrite, rename or warn (default)
* @param bool $index_document index document (search xapian module)
* @param bool $show_output print html messages
+ * @param string $fileKey
+ *
* @return array|bool
*/
public static function upload_document(
@@ -2829,6 +2831,21 @@ class DocumentManager
$sessionId
);
+ // Showing message when sending zip files
+ if ($new_path === true && $unzip == 1) {
+ if ($show_output) {
+ Display::display_confirmation_message(
+ get_lang('UplUploadSucceeded').'
',
+ false
+ );
+ }
+
+ return [
+ 'title' => $path,
+ 'url' => $path,
+ ];
+ }
+
if ($new_path) {
$documentId = DocumentManager::get_document_id(
$course_info,
@@ -2875,13 +2892,6 @@ class DocumentManager
);
}
- // Showing message when sending zip files
- if ($new_path === true && $unzip == 1 && $show_output) {
- Display::display_confirmation_message(
- get_lang('UplUploadSucceeded') . '
',
- false
- );
- }
if ($index_document) {
self::index_document(
@@ -3403,13 +3413,13 @@ class DocumentManager
$return = '';
if ($lp_id) {
if ($folderId === false) {
- $return .= '