HomePHP Developing a Modular Class For a PHP File Uploader
Developing a Modular Class For a PHP File Uploader
If you’re a PHP programmer who needs to learn the basic concepts surrounding the implementation of file uploads via the HTTP protocol, then look no further, because you’ve come to the right place. Welcome to the final installment of the series “Building file uploaders with PHP 5.” In a step-by-step process, this series teaches you how to build several PHP-driven file uploading applications by using not only a procedural approach, but the object-oriented paradigm as well.
Now that you’re aware of the topic that's covered by this series of articles, it’s time to refresh what was discussed in the last tutorial. As you’ll probably recall, during that particular part of the series, I went through the development of a custom PHP function, called “uploadFile()”, which, as its name implies, came in handy for uploading a selected file to a web server via a simple web form.
Apart from performing the file uploading process itself, the aforementioned PHP function was provided with the capacity to throw exceptions in response to different errors that might arise when a file is being uploaded to the web server. In this way, it implements a basic, yet effective, error handling mechanism.
So far, so good. At this stage, you've hopefully recalled how to build an expandable file uploading application with PHP 5 that uses only one custom function to transfer a target file from a client machine to a predefined web server. However, in the beginning, I said that I was going to teach you how to develop a brand new file uploading application using an object-oriented approach.
Therefore, this last part of the series will be entirely focused on building a highly modular PHP 5 class. It will encapsulate all the business logic required to perform file uploads via HTTP behind its API.
So, let’s not waste more time in preliminaries and start learning how to create a file uploading class with PHP 5. Let’s get going!