Join David Powers for an in-depth discussion in this video Planning the class's features, part of PHP: Uploading Files Securely.
…In the previous chapter, we created a basic script to upload the single file.…But it was far from perfect.…Although there was a hidden form field to set the maximum size for an individual…file, someone could easily create a form…of their own to get around that restriction.…No checks are made on the type of file being uploaded.…If the files are stored in the public folder, this presents a security risk.…There's no check…on filenames.…So they could contain spaces, causing problems on Linux servers or in URLs.…
Also, files with the same name as…an existing one, automatically overwrite the original.…The basic script handles only one file at a time.…And it would be difficult to reuse without adapting…the same script each time you want to use it.…To solve these shortcomings, we're going to create a custom class.…A class is basically a collection of…related variables and functions that are designed…to work together to perform a specific task, in this case to upload files.…
Variables defined inside the class are known as properties.…
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.