Reputation: 1026
I have a file on one server which is inside storage folder. I would like to transfer this file to an external server via ftp.
I've tried using https://github.com/GrahamCampbell/Laravel-Flysystem
But the issue is that it only allows me to update and read the file. So if lets say test.txt does not exist, it will return Undefined offset: 8 which I traced down to being file not found
This is the function that is breaking:
$fileName = "test2.txt"
$filePath = "path/to/file/to/transfer/test.txt"
$this->flysystem->connection('ftp')->write($fileName,$filePath);
File test2.txt does not exist on server 2
This functions allow me to update the file
$this->flysystem->connection('ftp')->put('test.txt','test');
File test.txt exist on server 2
Also I'm trying to transfer .zip files but testing on txt
Thanks
Upvotes: 1
Views: 6139
Reputation: 281
try this..
$stream = fopen("path/to/file/to/transfer/test.txt" , 'r+');
$this->flysystem->connection('ftp')->writeStream('uploads/test.txt', $stream);
fclose($stream);
Upvotes: 0