Php 在Laravel 5中创建目录并上载图像

Php 在Laravel 5中创建目录并上载图像,php,laravel,laravel-5,Php,Laravel,Laravel 5,当前,此代码将图像上载到存储/upload/目录,但我想将此图像上载到新创建的目录($directory)。 示例:storage/upload/1/test.jpg在put()方法中指定文件夹: Storage::disk('local')->put( $this->objProperty->id.'/'.$file->getFilename().'..$extension, File::get($File) ); 这需要更多的上下文,但我假设disk('local')是一个Flysystem

当前,此代码将图像上载到存储/upload/目录,但我想将此图像上载到新创建的目录(
$directory
)。
示例:storage/upload/1/test.jpg

put()
方法中指定文件夹:

Storage::disk('local')->put(
$this->objProperty->id.'/'.$file->getFilename().'..$extension,
File::get($File)
);

这需要更多的上下文,但我假设
disk('local')
是一个Flysystem“disk”,配置为指向存储/上载/是否正确?是的,在文件系统中,我已经分配了要上载的本地驱动程序及其创建上载目录和$directory=storage::makeDirectory($This->objProperty->id)//使用属性id创建目录。代码也根据id创建目录,但我可以将图像移动到该目录。
 $extension = $file->getClientOriginalExtension();
 $directory = Storage::makeDirectory($this->objProperty->id); //create directory using property id.
 Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));