Join David Powers for an in-depth discussion in this video Displaying the server limits, part of PHP: Uploading Files Securely.
…To make the file upload form more user-friendly, it's a…good idea to display the server limits in the web page.…You can do this by checking the server configuration,…and then hard coding the values into the page.…But actually, we've got all the tools necessary to get the values dynamically.…Rather than querying the server each time the…page loads, let's store the values as session variables.…So, we'll need to initialize…a session, and then we need to check if one of the session variables is being set.…
We only need to check one because if one…hasn't been set, none of them will have been.…So, if and not isset, and what we're looking…for is SESSION. And we'll look for maxfiles.…If that doesn't exist, we need to create it by querying the server configuration…and getting the value of max_file_uploads. So, SESSION maxfiles, and…then we can use ini_get and it's the max_file_uploads that…we are looking for. Then another SESSION variable,…call this one postmax.…
And we'll use that to get the value of post_max_size.…
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.