Join David Powers for an in-depth discussion in this video Using the exercise files, part of Uploading Files Securely with PHP.
If you're a subscriber to lynda.com, you'll have access to the exercise files that accompany this course. I've got them here in a folder on my desktop. The files are organized by chapter, and inside the folder for each chapter is a separate folder for each video. Because this is a PHP course, you'll need to copy the files into your server root. Throughout the course, I'll be using a folder called Uploads that I've created in my local testing environment, but feel free to work wherever is most convenient to you.
From chapter two, let's just switch to the files for chapter two, you'll be working almost exclusively with two files. Form.php contains an HTML form for uploading files. And then in the SRC folder, there's another folder called foundation.php, and in there is uploadFile.php, this contains a class definition. The code in each video builds on the previous one, so in most cases you'll find two versions of each file.
One with the code at the beginning of the video and the other with the code the way that it looks at the end. Some videos also have extra files, either to demonstrate a point or text files containing code ready to be pasted into the class definition I've also created a folder called For Upload on my desktop. This contains a selection of files used for testing the upload script. This folder is not included in the exercise files. I simply created it to make it easy to find a range of different types of files and file name conventions while recording the course.
You can use any files that you've got on your own computer. So that's how the exercise file are organized, let's get on with uploading files with PHP.
At the end of this course, you'll have a robust, flexible class that can be incorporated into many projects (including web forms) with just a few lines of code.
- How PHP handles file uploads
- Setting the maximum file size
- Moving the file to its destination
- Creating and using a namespaced class
- Displaying error messages
- Restricting unacceptable MIME types and file extensions
- Using the class
- Reporting errors
- Altering the user