Join David Powers for an in-depth discussion in this video Setting up to use the class, part of PHP: Uploading Files Securely.
…If you worked through the earlier chapters of this course, you…should be familiar with how to use the upload file class.…This movie and the next one, are mainly for the benefits of those…who've skipped straight to this chapter, or if you need to refresh your memory.…To use the class, you need a web page with a form that contains a file input field.…In my editing program, I've got open form.php and you can find a copy of…this file in the exercise files for this movie.…Let's take a quick look at what this file contains.…
Above the doctype is a small PHP block, on line 2 max is set to 50 times 1024.…1,024 is the number of bytes in a kilobyte.…So this'll be used to set the maximum size of an upload file to 50 kb.…Obviously if you want it to be a different value say 100 or 150, all you…need to do is to change the 50 and PHP will do the calculation for you.…Line 3 result is an empty array.…
This will be used to store the results of the upload.…And those results will be displayed by the PHP block…on lines 14 through to 20 as an unordered list.…
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
Skill Level Intermediate
1. File-Upload Basics
2. Creating a File-Upload Class
Checking the error level5m 7s
3. Making the Class More Secure
4. Handling Multiple File Uploads
5. Using the Class
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.