Laravel 5.3 Storage::put creates a directory with the file name Laravel 5.3 Storage::put creates a directory with the file name laravel laravel

Laravel 5.3 Storage::put creates a directory with the file name


you need to provide the file contents in the second argument not file object, try this:

Storage::disk('local')->put($newFilename, file_get_contents($file));


This happened because you specify the directory to store as filename. The newFilename, should be the directory name such as 'images'. Refer to this line

Storage::disk('local')->put($newFilename, $file);

So you could change this to

Storage::disk('local')->putFile('images', $file);

Then you will get the path stored at storage/app/images/234234234.jpg


Storage::disk('local')->putFileAs('', $file, $filenewname);