Where Laravel Storage save the files?


Question: Where Laravel Storage save the files?

hope you are doing really good today, I'm trying to copy a file using the function copy from Laravel Storage, but I don't know where it is saving them cause the first time looks normal but after the second shot I got an error about the file already exists, but I don't know where is saving it, this is my code, $dirDest should be a folder inside of my project but is not saving php error it there and I've already searched it in the ftp directory, hope you can help me.

$dirDest = 'temp-docs\temp.pdf'; Storage::disk('custom-ftp')->copy($this->document_path, $dirDest);```  Regards! 

Total Answers: 1


Answers 1: of Where Laravel Storage save the files?

Check the path you have configured for your 'custom-ftp' in filesystems.php. This part:

'custom-ftp' => [     ...     'root' => 'your/base/path',     ... ], 

You file copy will be located in this root folder + 'temp-docs\temp.pdf'

The copy function does not changes the driver. So it copies just inside of your ftp server.

To copy the file from one server to another (or your server) use a combination of get and put functions from the storage drivers.

$file = Storage::disk('my_ftp')->get($this->document_path); Storage::disk('other_ftp')->put('temp-docs\temp.pdf', $file); 

After that you will find the file of the other server root folder + 'temp-docs\temp.pdf'

I would also recommend you use the exists function to be sure that the file is there before you copy it.