Join David Powers for an in-depth discussion in this video Reporting errors with multiple uploads, part of PHP: Uploading Files Securely.
…A potential problem with multiple uploads is…that users will accidentally exceed the server limits.…Either on the maximum number of simultaneous uploads, or…the total amount of POST data that can be handled.…PHP logs the error internally but doesn't display it.…Still, that means we can detect the problem and inform the user.…In the PHP code block above the doctype in…the form, add a new line at the end of the block and create a variable…called error, and assign to it the value of error_get_last.…
This is a PHP function that returns an…array with details of the most recent error.…If there are no errors when the page loads, error will be null.…But if there are any problems, we'll have an associative…array with details of the most recent error.…And it has to go outside of this…conditional statement that checks whether POST upload is set.…Because POST upload won't exist if…the upload exceeded the limit of post_max_size.…
So we now need to display error if there is a value in there.…So scroll down a bit in the form.…
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.