I have 2 disks in Laravel.
One is the local disk, the other one is a FTP server which I need to upload my files to. They are both correctly configured.
I have attempted it this way:
Storage::disk('FTP')->copy('old/file1.jpg', 'new/file1.jpg');
This would only copy the file if it is already in the FTP server. I have also read the documentation and there seems to be no way to combine both in order to upload files.
Any suggestions?
@ceejayoz has a good answer, but as mentioned in the comments, this fetches, and then writes.
In order to use streams, the following can be used instead:
Storage::disk('FTP')->writeStream('new/file1.jpg', Storage::readStream('old/file1.jpg'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With