@@ -25,38 +25,41 @@ public function upload()
2525 // sanity check
2626 if ( ! Input::hasFile ('upload ' )) {
2727 // there ws no uploded file
28- return "You must choose a file! " ;
29- exit ;
28+ return 'You must choose a file! ' ;
3029 }
3130
3231 $ file = Input::file ('upload ' );
33- $ working_dir = Input::get ('working_dir ' );
34- $ destinationPath = base_path () . "/ " . $ this ->file_location ;
3532
36- if (strlen ($ working_dir ) !== '/ ' ) {
37- $ destinationPath .= $ working_dir . "/ " ;
33+ $ new_filename = $ this ->getNewName ($ file );
34+
35+ $ destinationPath = parent ::getPath ();
36+
37+ if (File::exists ($ destinationPath . $ new_filename )) {
38+ return 'A file with this name already exists! ' ;
3839 }
3940
40- $ filename = $ file ->getClientOriginalName ();
41- $ extension = $ file ->getClientOriginalExtension ();
42- $ new_filename = $ filename ;
41+ $ file ->move ($ destinationPath , $ new_filename );
4342
44- if (Config ::get ('lfm.rename_file ' ) === true ) {
45- $ new_filename = uniqid () . " . " . $ extension ;
43+ if (Session ::get ('lfm_type ' ) == ' Images ' ) {
44+ $ this -> makeThumb ( $ destinationPath , $ new_filename ) ;
4645 }
4746
48- if (File::exists ($ destinationPath . $ new_filename )) {
49- return "A file with this name already exists! " ;
50- exit ;
47+ if (Input::get ('uploadMode ' ) === 'express ' ) {
48+ # code...
5149 }
5250
53- Input::file ('upload ' )->move ($ destinationPath , $ new_filename );
51+ return 'OK ' ;
52+ }
5453
55- if (Session::get ('lfm_type ' ) == "Images " ) {
56- $ this ->makeThumb ($ destinationPath , $ new_filename );
54+ private function getNewName ($ file )
55+ {
56+ $ new_filename = $ file ->getClientOriginalName ();
57+
58+ if (Config::get ('lfm.rename_file ' ) === true ) {
59+ $ new_filename = uniqid () . '. ' . $ file ->getClientOriginalExtension ();
5760 }
5861
59- return " OK " ;
62+ return $ new_filename ;
6063 }
6164
6265 private function makeThumb ($ destinationPath , $ new_filename )
0 commit comments