Join David Powers for an in-depth discussion in this video Strengthening the setMaxSize() method, part of PHP: Uploading Files Securely.
…The set max size method that we've just created, doesn't take into account the…limits on file uploads controlled by the…server configuration that we discussed in chapter one.…We need to make sure that set max size doesn't accept a…value that exceeds the limit in the service upload max file size directive.…We'll also make the error message about size limits more user-friendly.…So let's get to work on set max size. We'll add a new line…at the beginning of the definition. And we can get the value of…upload max file size, using the built-in PHP function, in E_get.…
So a variable to store the value, we'll call it…server max equals in E_get. And the value that…we're looking for is upload_max_filesize.…The value of upload_max_filesize can be…specified over as bytes or using shorthand.…G for gigabytes, M for megabytes, and K for kilobytes.…We need to make sure that the value in Server Max is expressed as…bytes, so it can be compared to the value submitted to Set Max Size.…
We're also going to need to convert the value in bytes…
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.