@@ -42,9 +42,10 @@ public function __construct($files = null, $path = null, $disablePermissionCheck
4242 /**
4343 * @param Repository $config
4444 * @param Image $image
45+ * @param Filesystem $filesystem
4546 * @return CommandResult
4647 */
47- public function handle (Repository $ config ,Image $ image )
48+ public function handle (Repository $ config ,Image $ image, Filesystem $ filesystem )
4849 {
4950 // check if user has permission
5051 if ( ! $ this ->disablePermissionChecking )
@@ -65,11 +66,11 @@ public function handle(Repository $config,Image $image)
6566
6667 // save the file
6768 $ file ->move (
68- $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this ->normalizePath ( $ path ),
69+ $ this ->getCurrentFullPath ( $ config , $ path ),
6970 $ normalizedFileName
7071 );
7172
72- $ filePath = $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this ->normalizePath ( $ path ). ' / ' .$ normalizedFileName ;
73+ $ filePath = $ this ->getCurrentFullPath ( $ config , $ path ).$ normalizedFileName ;
7374 $ file_name = pathinfo ($ filePath , PATHINFO_FILENAME );
7475 $ extension = pathinfo ($ filePath , PATHINFO_EXTENSION );
7576
@@ -80,11 +81,18 @@ public function handle(Repository $config,Image $image)
8081 {
8182 foreach ($ sizes as $ key => $ dimension )
8283 {
84+ $ targetDir = $ this ->getCurrentFullPath ($ config ,$ path ).$ key .DIRECTORY_SEPARATOR ;
85+
86+ if ( ! $ filesystem ->exists ($ targetDir ) )
87+ {
88+ $ filesystem ->makeDirectory ($ this ->normalizePath ($ path ).DIRECTORY_SEPARATOR .$ key .DIRECTORY_SEPARATOR );
89+ }
90+
8391 $ image ::createThumbnail (
8492 $ filePath ,
8593 $ dimension [0 ],
8694 $ dimension [1 ],
87- $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this -> normalizePath ( $ path ). ' / ' . $ this -> produceThumbFileName ( $ file_name , $ key , $ extension)
95+ $ targetDir . $ file_name . ' . ' . $ extension
8896 );
8997 }
9098 }
@@ -121,6 +129,16 @@ protected function produceThumbFileName($file_name, $file_size_name, $file_exten
121129 return $ file_name .'_ ' .$ file_size_name .'. ' .$ file_extension ;
122130 }
123131
132+ /**
133+ * @param Repository $config
134+ * @param string $path
135+ * @return string
136+ */
137+ protected function getCurrentFullPath ($ config , $ path )
138+ {
139+ return $ config ->get ('filesystems.disks.local.root ' ).DIRECTORY_SEPARATOR .$ this ->normalizePath ($ path ).DIRECTORY_SEPARATOR ;
140+ }
141+
124142 /**
125143 * when uploading a file, we will remove dashes because dashes are use in UI as size convention
126144 *
0 commit comments