Join David Powers for an in-depth discussion in this video Creating and using a namespaced class, part of PHP: Uploading Files Securely.
…Since PHP 5.3, namespaces have been used to simplify the organization…of classes, and to avoid conflicts with other libraries or frameworks.…Before namespaces, frameworks frequently used long,…descriptive names for classes, such as Zend_File_Transfer_Adapter_Http.…Namespaces make such long names a thing of the past.…A common…convention is to store namespace classes in a top-level…folder called SRC, or Source. So I've created a…folder called SRC in the top-level of my testing site.…
And inside the SRC folder you should have a sub-folder for each namespace.…My domain name is foundationphp.com so I'm going to use foundationphp as…the namespace.…And it's in this folder that we'll create the definition for the upload file class.…So in your testing environment, create two…folders, source and then inside there foundation php.…And then inside foundation php we need to create a blank php file.…
So we need to save that file. And we'll save it inside source…foundation php. And the name of the file should…be, UploadFile.php, upload file is all one word, with a capital U, and a capital F.…
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.