With PHP, there's always more than one way to accomplish a particular task.
Take file upload, for example. Sure, you can do it the traditional way, using HTTP file upload and transferring the file directly to a location on your Web server's disk. Or you can do it the more exotic way, and use the FTP protocol to upload in a two-step process: from your local disk to a Web server, and then to an FTP server.
The grumpy programmer speaks: I’ve seen too many scripts over the years where the author just calls some external program with an exec or system command, usually without checking for a return value, and then continues on his merry way. This can cause race conditions (i.e. two interdependent processes each not knowing when the other has finished, and stepping on each other’s toes) and unchecked errors, which can in turn cause serious failures. If you need to make use of an external program from within a PHP script, and you want to avoid these problems, then this essay is for you. My example script is for managing an sftp connection, but the principals can be applied to any interaction that requires communication between your script and an external process.
Highly sophisticated applications do not only consist of web forms processed interactively. With underlying modules interfacing external services and different technologies managing a clever workflow the application quickly becomes quite complex. This article introduces the technical details of setting up a batch system which uses FTP communication with encrypted files. Possibly even more important, a basic understanding of an approach which interfaces heterogeneous platforms with PHP as the "glue language" is provided.
In this article Mitchell shares his FTP wrapper class which he has written in PHP. It includes error checking and many useful functions.
Ever wondered how to make your own FTP client with PHP? Look no further. In this article Mitchell teaches you everything you need to do just that.








