Sunday, March 5, 2017

How to move a file located outside the public folder?

I am right now trying to figure out how I can move a file that got temporarily stored in storage/app/chunks to a public folder in order to save it there permanently.

I have tried

$chunk_file_path = "/storage/app/chunks/The Simpsons Movie - 1080p Trailer.mp4-YMtmuO4cEG4ejK6knZOEzZCxVie0NwDgdFqggThG-147399359.part";
$chunk_move_path = "uploads/The Simpsons Movie - 1080p Trailer.mp4-YMtmuO4cEG4ejK6knZOEzZCxVie0NwDgdFqggThG-147399359.part";
Storage::move($chunk_file_path, $chunk_move_path);

The problem I encounter is

FileNotFoundException in Filesystem.php line 385: File not found at path: storage/app/chunks/The Simpsons Movie - 1080p Trailer.mp4-YMtmuO4cEG4ejK6knZOEzZCxVie0NwDgdFqggThG-147399359.part

The file does exist, but it seems like root folder is automatically the public folder of the Laravel installation. So it is looking in public/storage/app/chunks/The Simpsons Movie - 1080p Trailer.mp4-YMtmuO4cEG4ejK6knZOEzZCxVie0NwDgdFqggThG-147399359.part and can't find it obviously, because it is not in the public folder hierarchy.

Any help is highly appreciated.



via Chris Palmer Breuer

Advertisement