diff --git a/src/controllers/UploadController.php b/src/controllers/UploadController.php index 16ef34b9..1cbef929 100644 --- a/src/controllers/UploadController.php +++ b/src/controllers/UploadController.php @@ -37,27 +37,30 @@ public function upload() return $e->getMessage(); } - $file = Input::file('upload'); + $files = Input::file('upload'); - $new_filename = $this->getNewName($file); + foreach($files as $file) + { + $new_filename = $this->getNewName($file); - $dest_path = parent::getPath('directory'); + $dest_path = parent::getPath('directory'); - if (File::exists($dest_path . $new_filename)) { - return Lang::get('laravel-filemanager::lfm.error-file-exist'); - } + if (File::exists($dest_path . $new_filename)) { + return Lang::get('laravel-filemanager::lfm.error-file-exist'); + } - $file->move($dest_path, $new_filename); + $file->move($dest_path, $new_filename); - if ('Images' === $this->file_type) { - $this->makeThumb($dest_path, $new_filename); - } + if ('Images' === $this->file_type) { + $this->makeThumb($dest_path, $new_filename); + } - Event::fire(new ImageWasUploaded(realpath($dest_path.'/'.$new_filename))); + Event::fire(new ImageWasUploaded(realpath($dest_path.'/'.$new_filename))); - // upload via ckeditor 'Upload' tab - if (!Input::has('show_list')) { - return $this->useFile($new_filename); + // upload via ckeditor 'Upload' tab + if (!Input::has('show_list')) { + return $this->useFile($new_filename); + } } return 'OK'; @@ -69,36 +72,51 @@ private function uploadValidator() $expected_file_type = $this->file_type; $is_valid = false; + $force_invalid = false; - $file = Input::file('upload'); - if (empty($file)) { - throw new \Exception(Lang::get('laravel-filemanager::lfm.error-file-empty')); - } - if (!$file instanceof UploadedFile) { - throw new \Exception(Lang::get('laravel-filemanager::lfm.error-instance')); - } + $files = Input::file('upload'); + + foreach($files as $file) + { + if (empty($file)) { + throw new \Exception(Lang::get('laravel-filemanager::lfm.error-file-empty')); + } + if (!$file instanceof UploadedFile) { + throw new \Exception(Lang::get('laravel-filemanager::lfm.error-instance')); + } - $mimetype = $file->getMimeType(); + $mimetype = $file->getMimeType(); - if ($expected_file_type === 'Files') { - $config_name = 'lfm.valid_file_mimetypes'; - $valid_mimetypes = Config::get($config_name, $this->default_file_types); - } else { - $config_name = 'lfm.valid_image_mimetypes'; - $valid_mimetypes = Config::get($config_name, $this->default_image_types); - } + if ($expected_file_type === 'Files') { + $config_name = 'lfm.valid_file_mimetypes'; + $valid_mimetypes = Config::get($config_name, $this->default_file_types); + } else { + $config_name = 'lfm.valid_image_mimetypes'; + $valid_mimetypes = Config::get($config_name, $this->default_image_types); + } - if (!is_array($valid_mimetypes)) { - throw new \Exception('Config : ' . $config_name . ' is not set correctly'); - } + if (!is_array($valid_mimetypes)) { + $force_invalid = true; + throw new \Exception('Config : ' . $config_name . ' is not set correctly'); + } - if (in_array($mimetype, $valid_mimetypes)) { - $is_valid = true; + $is_valid = false; + + if (in_array($mimetype, $valid_mimetypes)) { + $is_valid = true; + } + + if (false === $is_valid) { + $force_invalid = true; + throw new \Exception(Lang::get('laravel-filemanager::lfm.error-mime') . $mimetype); + } } - if (false === $is_valid) { - throw new \Exception(Lang::get('laravel-filemanager::lfm.error-mime') . $mimetype); + if($force_invalid) + { + return false; } + return $is_valid; } diff --git a/src/lang/en/lfm.php b/src/lang/en/lfm.php index be6875a1..2443f336 100644 --- a/src/lang/en/lfm.php +++ b/src/lang/en/lfm.php @@ -16,7 +16,7 @@ 'title-page' => 'File Manager', 'title-panel' => 'Laravel FileManager', - 'title-upload' => 'Upload File', + 'title-upload' => 'Upload File(s)', 'title-view' => 'View File', 'title-root' => 'Files', 'title-shares' => 'Shared Files', @@ -29,7 +29,7 @@ 'type-folder' => 'Folder', 'message-empty' => 'Folder is empty.', - 'message-choose' => 'Choose File', + 'message-choose' => 'Choose File(s)', 'message-delete' => 'Are you sure you want to delete this item?', 'message-name' => 'Folder name:', 'message-rename' => 'Rename to:', @@ -47,7 +47,7 @@ 'error-other' => 'An error has occured: ', 'error-too-large' => 'Request entity too large!', - 'btn-upload' => 'Upload File', + 'btn-upload' => 'Upload File(s)', 'btn-uploading' => 'Uploading...', 'btn-close' => 'Close', 'btn-crop' => 'Crop', diff --git a/src/lang/fr/lfm.php b/src/lang/fr/lfm.php index f669d2ab..2fe4c76a 100644 --- a/src/lang/fr/lfm.php +++ b/src/lang/fr/lfm.php @@ -16,7 +16,7 @@ 'title-page' => 'Gestionnaire de fichiers', 'title-panel' => 'Laravel FileManager', - 'title-upload' => 'Envoyer un fichier', + 'title-upload' => 'Envoyer un/des fichier(s)', 'title-view' => 'Voir le fichier', 'title-root' => 'Fichiers', 'title-shares' => 'Shared Files', @@ -29,7 +29,7 @@ 'type-folder' => 'Dossier', 'message-empty' => 'Dossier est vide', - 'message-choose' => 'Choisir un fichier', + 'message-choose' => 'Choisir un/des fichier(s)', 'message-delete' => 'Êtes-vous sûr de vouloir supprimer ce fichier ?', 'message-name' => 'Nom du dossier:', 'message-rename' => 'Renommer le dossier:', @@ -45,7 +45,7 @@ 'error-instance' => 'The uploaded file should be an instance of UploadedFile', 'error-invalid' => 'Invalid upload request', - 'btn-upload' => 'Envoyer le fichier', + 'btn-upload' => 'Envoyer le/les fichier(s)', 'btn-uploading' => 'Envoi...', 'btn-close' => 'Fermer', 'btn-crop' => 'Rogner', diff --git a/src/views/index.blade.php b/src/views/index.blade.php index e4652433..68018586 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -114,7 +114,7 @@
- +
diff --git a/src/views/script.blade.php b/src/views/script.blade.php index c70741c5..6055e5d3 100644 --- a/src/views/script.blade.php +++ b/src/views/script.blade.php @@ -56,7 +56,7 @@ function showResponse(responseText, statusText, xhr, $form) { if (responseText != 'OK'){ notify(responseText); } - $('#upload').val(''); + $('input#upload').val(''); loadItems(); }