Skip to content

Commit 48aac99

Browse files
authored
Merge pull request #93 from atzeteppema/master
Added error handler to file upload and Corrected double file extensions in config
2 parents 26daa89 + 73523b1 commit 48aac99

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/config/lfm.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
// file extensions array, only for showing file information, it won't affect the upload process.
5353
'file_type_array' => [
5454
'pdf' => 'Adobe Acrobat',
55+
'doc' => 'Microsoft Word',
5556
'docx' => 'Microsoft Word',
56-
'docx' => 'Microsoft Word',
57-
'xls' => 'Microsoft Excel',
5857
'xls' => 'Microsoft Excel',
58+
'xlsx' => 'Microsoft Excel',
5959
'zip' => 'Archive',
6060
'gif' => 'GIF Image',
6161
'jpg' => 'JPEG Image',
@@ -68,10 +68,10 @@
6868
// file extensions array, only for showing icons, it won't affect the upload process.
6969
'file_icon_array' => [
7070
'pdf' => 'fa-file-pdf-o',
71+
'doc' => 'fa-file-word-o',
7172
'docx' => 'fa-file-word-o',
72-
'docx' => 'fa-file-word-o',
73-
'xls' => 'fa-file-excel-o',
7473
'xls' => 'fa-file-excel-o',
74+
'xlsx' => 'fa-file-excel-o',
7575
'zip' => 'fa-file-archive-o',
7676
'gif' => 'fa-file-image-o',
7777
'jpg' => 'fa-file-image-o',

src/lang/en/lfm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
'error-mime' => 'Unexpected MimeType: ',
4545
'error-instance' => 'The uploaded file should be an instance of UploadedFile',
4646
'error-invalid' => 'Invalid upload request',
47+
'error-other' => 'An error has occured: ',
48+
'error-too-large' => 'Request entity too large!',
4749

4850
'btn-upload' => 'Upload File',
4951
'btn-uploading' => 'Uploading...',

src/views/script.blade.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
$('#upload-btn').click(function () {
4242
var options = {
4343
beforeSubmit: showRequest,
44-
success: showResponse
44+
success: showResponse,
45+
error: showError
4546
};
4647
4748
function showRequest(formData, jqForm, options) {
@@ -59,6 +60,17 @@ function showResponse(responseText, statusText, xhr, $form) {
5960
loadItems();
6061
}
6162
63+
function showError(jqXHR, textStatus, errorThrown) {
64+
$('#upload-btn').html('{{ Lang::get("laravel-filemanager::lfm.btn-upload") }}');
65+
if (jqXHR.status == 413) {
66+
notify('{{ Lang::get("laravel-filemanager::lfm.error-too-large") }}');
67+
} else if (textStatus == 'error') {
68+
notify('{{ Lang::get("laravel-filemanager::lfm.error-other") }}' + errorThrown);
69+
} else {
70+
notify('{{ Lang::get("laravel-filemanager::lfm.error-other") }}' + textStatus + '<br>' + errorThrown);
71+
}
72+
}
73+
6274
$('#uploadForm').ajaxSubmit(options);
6375
return false;
6476
});

0 commit comments

Comments
 (0)