在 Laravel 5 中创建目录并上传图片

Create directory and upload image in Laravel 5

 $extension = $file->getClientOriginalExtension();
 $directory = Storage::makeDirectory($this->objProperty->id); //create directory using property id.
 Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));

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

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

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