Daniel H
Daniel H

Reputation: 2925

PHP FTP transfer

I have files that are automatically uploaded onto a server from mobile phones, and I need to automatically transfer these files from the server to another server using PHP.

Could someone please explain how I would do this?

Thanks for any help

Upvotes: 1

Views: 792

Answers (1)

Piskvor left the building
Piskvor left the building

Reputation: 92752

PHP has FTP functionality built in with FTP wrappers:

Allows read access to existing files and creation of new files via FTP. If the server does not support passive mode ftp, the connection will fail.

This means you can use FTP like any other file - an extremely simple example:

<?php
$data = file_get_contents('some/other/file.txt');
$fname = "ftp://name:[email protected]:21/some/path/filename.txt";
file_put_contents($fname,$data);
?>

Upvotes: 2

Related Questions