My goal here is simply tackling file uploads from a hands-on point of view and discarding all of those additional configuration settings that must be performed in the web server. Therefore, in this series of articles, I’m going to show you how to build some file uploading mechanisms with PHP 5, which, due their intrinsic modularity, can be easily integrated into other existing PHP applications with minor hassles.
If you're a PHP developer who has built a certain number of web applications, then it's quite probable that you've already worked with HTTP file uploads. They play a relevant role in the business logic of any PHP program that permits users to transfer specific files from their client computers to a web server via a web-based front-end, which is generally represented by an online form.
Indeed, file uploads have been supported by PHP for a long time. Even though they're relatively easy to implement in real world conditions by way of the useful set of native functions provided by the language, at the same time they require you to deal with a number of settings, which, in normal conditions, are beyond the scope of an average PHP programmer.
As you might know, handling HTTP file uploads with PHP not only implies that they must first be enabled on the php.ini file, but also that it's necessary to create a complete "writable" environment in the web server so user files can be uploaded seamlessly into a specified directory without getting any intimidating access-denied server responses.
Of course, setting up this friendly environment in the web server properly isn't always so feasible for a PHP developer who works with a shared hosting service, since this process naturally demands the intervention of a system administrator. But despite the issues, in general terms, file uploads can be implemented quite easily with PHP.
As you'll see in the next few lines, first I'm going to teach you how to handle file uploads using a procedural approach, and then, with the topic well underway, by way of the object-oriented paradigm.
Having introduced you to the subject of this article series, let's learn how to implement file uploads with PHP 5. Let's begin now!