Using PHP Context Streams to FTP files onto another server.

Here I’m going to show you how to use PHP streams to connect to an FTP server, create a new file and place content into this file. We also need an additional stream context telling PHP to overwrite the file if it exists.  A common stumble I see in scripts like this all the time.

You could also assign to the $content value the entirety of a file on your server using file_get_content() or perhaps a generated CVS or JSON or XML data file.

Author: Richard Soares

Director of Software Development & Senior Technical Project Manager