Join David Powers for an in-depth discussion in this video Understanding how the $_FILES array handles multiple files, part of PHP: Uploading Files Securely.
…Before embarking on changes to the upload file class, it's…important to understand how HTML and PHP handle multiple file uploads.…The webpage that I've got open contains a file input field here on line 23.…And above the doctype, we've got a PHP code block that…uses print_r to inspect the content of the files superglobal array.…The simple way to enable…multiple file uploads in a form is to add an empty…pair of square brackets after the name of the file input field.…
So here we are on line 23, the name is filename.…If we add those square brackets at the end there,…that tells PHP to store the files as an array.…Note that it must go on the name, it's not on the id.…You also need to add the multiple attribute…to the input tag. The multiple attribute is new to HTML 5…but it's supported by all modern browsers except Internet Explorer 9 and earlier.…Online two, the value of max has been set to be equivalent…of 50 kilobytes, so that's going used by max file size down here.…
So let's save that page and run it in the browser and see what happens…
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.