HomePHP Retrieving Information on Selected Files with a PHP 5 File Uploader
Retrieving Information on Selected Files with a PHP 5 File Uploader
The initial script in the first tutorial of this series lacked some important features, such as the implementation of an effective error handling module and the ability to check the MIME type and size of the file being uploaded. In this second installment of the series, Iím going to improve the logic of the script from the first tutorial to provide it with the capacity to retrieve useful information concerning the entire file uploading process.
As you know, nowadays the web has plenty of sites that provide visitors with the ability to easily upload their files to a web server. And this phenomenon, for bad or good, is a crucial part of the so-called ďsocial web.Ē But regardless of what you may think of these kinds of websites, in all these cases, thereís a backend application that performs these file uploads via the HTTP protocol.
However, thereís no need to build a huge social website to implement a file uploading mechanism. And you, as a PHP developer, are probably well aware of this. Handing file uploads with PHP is one of the most popular topics to learn these days, and thatís the reason I decided to write this article series. In its different tutorials, youíll learn the basic concepts required to build a file uploading application with PHP 5, first by using a procedural approach and then via the object-oriented paradigm.
Now that I've introduced you to the main subject of this group of articles, Iíd like to quickly refresh the concepts that I deployed in the first part of the series, in case you didnít have the chance to read it. In simple terms, I explained how to create a basic file uploading script in PHP 5 by using a combination of the ďmove_uploaded_file()Ē PHP native function and the $_FILES superglobal array.
Naturally, first it was necessary to construct a simple front-end composed of a typical web form that provides users with an intuitive mechanism to browse files in the client machine, then select one of them, and finally upload it to the server via the aforementioned PHP script. However, this was only an introductory approach for building a file uploader with PHP 5.
As you know, small moves can go a long way, so letís continue learning how to handle file uploads with PHP 5. Letís get going!