0Pricing
PHP Academy · Lesson

Handling File Uploads

Process uploaded files safely using the _FILES superglobal.

PHP File Uploads Overview

PHP handles file uploads through the $_FILES superglobal. The form must use method="POST" and enctype="multipart/form-data".

HTML Upload Form

The HTML form setup for single and multiple file uploads:

<!-- Single file -->
<form method="POST" action="upload.php"
      enctype="multipart/form-data">
    <input type="file" name="document">
    <button>Upload</button>
</form>

<!-- Multiple files -->
<form method="POST" enctype="multipart/form-data">
    <input type="file" name="photos[]" multiple>
    <button>Upload All</button>
</form>

All lessons in this course

  1. Reading Files with PHP
  2. Writing and Appending to Files
  3. Working with Directories
  4. Handling File Uploads
← Back to PHP Academy