PHP AdvancedLesson 35Free preview
PHP File Upload
This lesson is part of PHP · All levels
Summary
PHP supports uploading files from a form to a server, such as photos or document attachments. You need to set the multipart enctype/form-data attribute to the form, and then read the file information from the superglobal $_FILES. This lesson also discusses validating file types and sizes for security reasons.
Key points
- The upload form must have enctype="multipart/form-data"
- $_FILES stores the name, size, type, and location of the file while
- Tmp_name is the temporary location of a file when processed on the server
- Validate the file type and size, then rename it before saving it
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.