Media manager improves, alert when the file type is not supported and maximum load file
This commit is contained in:
parent
7335196208
commit
088179f1fb
|
@ -37,6 +37,8 @@ $numberOfPages = count($listOfFilesByPage);
|
|||
-->
|
||||
<h3 class="mt-2 mb-3"><?php $L->p('Upload'); ?></h3>
|
||||
|
||||
<div id="jsalertMedia" class="alert alert-warning d-none" role="alert"></div>
|
||||
|
||||
<!-- Form and Input file -->
|
||||
<form name="bluditFormUpload" id="jsbluditFormUpload" enctype="multipart/form-data">
|
||||
<div class="custom-file">
|
||||
|
@ -97,6 +99,14 @@ function cleanTable() {
|
|||
$('#jsbluditMediaTable').empty();
|
||||
}
|
||||
|
||||
function showMediaAlert(message) {
|
||||
$("#jsalertMedia").html(message).removeClass('d-none');
|
||||
}
|
||||
|
||||
function hideMediaAlert() {
|
||||
$("#jsalertMedia").addClass('d-none');
|
||||
}
|
||||
|
||||
// Show the files in the table
|
||||
function displayFiles(files) {
|
||||
if (!Array.isArray(files)) {
|
||||
|
@ -143,6 +153,8 @@ function getFiles(pageNumber) {
|
|||
function(data) { // success function
|
||||
if (data.status==0) {
|
||||
displayFiles(data.files);
|
||||
} else {
|
||||
console.log(data.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -158,6 +170,8 @@ function deleteMedia(filename) {
|
|||
function(data) { // success function
|
||||
if (data.status==0) {
|
||||
getFiles(1);
|
||||
} else {
|
||||
console.log(data.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -211,6 +225,9 @@ $(document).ready(function() {
|
|||
$("#jsbluditProgressBar").width("0");
|
||||
// Get the files for the first page, this include the files uploaded
|
||||
getFiles(1);
|
||||
} else {
|
||||
$("#jsbluditProgressBar").width("0");
|
||||
showMediaAlert(data.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ foreach ($_FILES['bluditInputFiles']['name'] as $key=>$filename) {
|
|||
|
||||
// Check for errors
|
||||
if ($_FILES['bluditInputFiles']['error'][$key] != 0) {
|
||||
$message = 'Error occurred uploading the image, max file size allowed: '.ini_get('upload_max_filesize');
|
||||
$message = $L->g('Maximum load file size allowed:').' '.ini_get('upload_max_filesize');
|
||||
Log::set($message, LOG_TYPE_ERROR);
|
||||
ajaxResponse(1, $message);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ foreach ($_FILES['bluditInputFiles']['name'] as $key=>$filename) {
|
|||
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$fileExtension = Text::lowercase($fileExtension);
|
||||
if (!in_array($fileExtension, $allowedExtensions) ) {
|
||||
$message = 'Extension file not supported.';
|
||||
$message = $L->g('File type is not supported. Allowed types:').' '.implode(', ',$allowedExtensions);
|
||||
Log::set($message, LOG_TYPE_ERROR);
|
||||
ajaxResponse(1, $message);
|
||||
}
|
||||
|
|
|
@ -376,5 +376,7 @@
|
|||
"thumbnail": "Thumbnail",
|
||||
"thumbnail-width-in-pixels": "Thumbnail width in pixels (px).",
|
||||
"thumbnail-height-in-pixels": "Thumbnail height in pixels (px).",
|
||||
"thumbnail-quality-in-percentage": "Thumbnail quality in percentage (%)."
|
||||
"thumbnail-quality-in-percentage": "Thumbnail quality in percentage (%).",
|
||||
"maximum-load-file-size-allowed:": "Maximum load file size allowed:",
|
||||
"file-type-is-not-supported": "File type is not supported. Allowed types:"
|
||||
}
|
Loading…
Reference in New Issue