Join David Powers for an in-depth discussion in this video Changing the class's defaults, part of PHP: Uploading Files Securely.
…The public methods of the upload file class have…been designed to make it simple to change most defaults.…But you might want to change some of them permanently, also the list of permitted…Mime types and of potentially risky file name…extensions, have been hardcoded into the class definition.…To make changes, open uploadfile.php.…And most of the defaults can be changed in the property…declarations at the top of the class definition.…First one that you might want to change is this one here, maxSize.…
This sets the maximum limit for individual files that can be uploaded.…It's expressed in bytes, and is currently set to 50 kilobytes.…It's important to note that the value of max size must be an integer.…You can't use calculation.…So for example,…if you want to change this to 150 kilobytes, and you try to do this,…150 times 1024, you'll see that I…get a little underline here, and a message here saying that I've got a syntax error.…
You can't have a calculation, it must be a fixed value.…So if you want it to be 150 kilobytes, you would need to put in the correct value,…
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.