mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-07-31 18:30:20 +02:00
Files Manager Improvements - Drug'n'Drop uploader - error handler updates #94
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
leftImg : "<?php echo Option::get('siteurl'); ?>/public/assets/img/chocolat/left.gif",
|
||||
rightImg : "<?php echo Option::get('siteurl'); ?>/public/assets/img/chocolat/right.gif",
|
||||
closeImg : "<?php echo Option::get('siteurl'); ?>/public/assets/img/chocolat/close.gif",
|
||||
loadingImg : "<?php echo Option::get('siteurl'); ?>/public/assets/img/chocolat/loading.gif",
|
||||
loadingImg : "<?php echo Option::get('siteurl'); ?>/public/assets/img/chocolat/loading.gif"
|
||||
});
|
||||
|
||||
$('input').iCheck({
|
||||
|
@@ -67,6 +67,11 @@ class FilesmanagerAdmin extends Backend
|
||||
if (Security::check(Request::get('token'))) {
|
||||
|
||||
File::delete($files_path.Request::get('delete_file'));
|
||||
if (!is_file($files_path.Request::get('delete_file'))) {
|
||||
Notification::set('success', __('File was deleted', 'system'));
|
||||
} else {
|
||||
Notification::set('error', __('File was not deleted', 'system'));
|
||||
}
|
||||
Request::redirect($site_url.'/admin/index.php?id=filesmanager&path='.$path);
|
||||
|
||||
} else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); }
|
||||
@@ -98,13 +103,32 @@ class FilesmanagerAdmin extends Backend
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
$error = false;
|
||||
if ($_FILES['file']) {
|
||||
if ( ! in_array(File::ext($_FILES['file']['name']), $forbidden_types)) {
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $files_path.Security::safeName(basename($_FILES['file']['name'], File::ext($_FILES['file']['name'])), '-', true).'.'.File::ext($_FILES['file']['name']));
|
||||
Request::redirect($site_url.'/admin/index.php?id=filesmanager&path='.$path);
|
||||
$filepath = $files_path.Security::safeName(basename($_FILES['file']['name'], File::ext($_FILES['file']['name'])), '-', true).'.'.File::ext($_FILES['file']['name']);
|
||||
$uploaded = move_uploaded_file($_FILES['file']['tmp_name'], $filepath);
|
||||
if ($uploaded !== false && is_file($filepath)) {
|
||||
Notification::set('success', __('File was uploaded', 'system'));
|
||||
} else {
|
||||
$error = 'File was not uploaded';
|
||||
}
|
||||
} else {
|
||||
$error = 'Forbidden file type';
|
||||
}
|
||||
} else {
|
||||
$error = 'File was not uploaded';
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
Notification::set('error', __($error, 'system'));
|
||||
}
|
||||
|
||||
if (Request::post('dragndrop')) {
|
||||
Request::shutdown();
|
||||
} else {
|
||||
Request::redirect($site_url.'/admin/index.php?id=filesmanager&path='.$path);
|
||||
}
|
||||
} else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); }
|
||||
}
|
||||
|
||||
@@ -172,7 +196,8 @@ class FilesmanagerAdmin extends Backend
|
||||
->assign('files_path', $files_path)
|
||||
->assign('fileuploader', array(
|
||||
'uploadUrl' => $site_url.'/admin/index.php?id=filesmanager&path='.$path,
|
||||
'csrf' => Security::token()
|
||||
'csrf' => Security::token(),
|
||||
'errorMsg' => __('Upload server error', 'system')
|
||||
))->display();
|
||||
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@ $.monstra.fileuploader = {
|
||||
|
||||
conf: {
|
||||
uploadUrl: '',
|
||||
csrf: ''
|
||||
csrf: '',
|
||||
errorMsg: ''
|
||||
},
|
||||
|
||||
init: function(conf){
|
||||
@@ -45,6 +46,7 @@ $.monstra.fileuploader = {
|
||||
var fd = new FormData();
|
||||
fd.append('file', files[i]);
|
||||
fd.append('upload_file', 'upload_file');
|
||||
fd.append('dragndrop', '1');
|
||||
fd.append('csrf', $.monstra.fileuploader.conf.csrf);
|
||||
//this.setFileNameSize(files[i].name, files[i].size);
|
||||
|
||||
@@ -78,10 +80,15 @@ $.monstra.fileuploader = {
|
||||
success: function(data){
|
||||
$.monstra.fileuploader.setProgress(100);
|
||||
location.href = $.monstra.fileuploader.conf.uploadUrl;
|
||||
/*$('#fuProgress').fadeOut('slow', function(){
|
||||
$('#fuProgress').css({width: 0, display: 'block'});
|
||||
},
|
||||
error: function(){
|
||||
Messenger().post({
|
||||
type: 'error',
|
||||
message : $.monstra.fileuploader.conf.errorMsg,
|
||||
hideAfter: 3
|
||||
});
|
||||
$('#fuProgress').animate({ width: 0 }, 1);
|
||||
$('#fuPlaceholder').show();
|
||||
});*/
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@@ -135,12 +135,12 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h4 class="modal-title" id="myModalLabel">Create New File</h4>
|
||||
<h4 class="modal-title">Create New File</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form role="form">
|
||||
<label for="directoryName">File Name</label>
|
||||
<input type="text" class="form-control" id="directoryName">
|
||||
<label for="cdDirectoryName">File Name</label>
|
||||
<input type="text" class="form-control" id="cdDirectoryName">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
Reference in New Issue
Block a user