Is there anyway to send files to the mikrotik using PHP ie send folder from /location/hotspot to mikrotik?
Patrick
Is there anyway to send files to the mikrotik using PHP ie send folder from /location/hotspot to mikrotik?
Patrick
FTP would be the easiest and most efficient way, e.g.
$ftp = ftp_connect('192.168.0.1');
ftp_login($ftp, 'admin', 'password');
ftp_put($ftp, '/hotspot/file.txt', '/location/hotspot/file.txt', FTP_BINARY);
(see PHP’s FTP functions for details)
Alternatively, using the API:
$util = new RouterOS\Util($client);
$util->filePutContents('/hotspot/file.txt', file_get_contents('/location/hotspot/file.txt'));
but that takes a penalty of 2 seconds per file, so it’s not a recommended way if performance is at all important.
Regardless of the approach, to copy an entire folder, you’d need to traverse it using RecursiveDirectoryIterator, similarly to the example shown, and prepend the path to each file when doing the putting.