InitPHP Upload validates and stores uploaded files behind a single adapter interface. Point it at the local filesystem, an FTP/FTPS server, or an Amazon S3 bucket without changing the calling code.
| Guide | What it covers |
|---|---|
| Getting started | Install, the two ways to load a file, your first upload. |
The File object |
Every accessor on File, plus setPost() and setPath(). |
| Validation | Extension, MIME type and size restrictions and how they are checked. |
| Local adapter | Storing files on disk, move vs. copy, directory creation. |
| FTP adapter | FTP/FTPS uploads, passive mode, remote directories. |
| S3 adapter | Amazon S3 uploads, buckets, keys and ACLs. |
| Exceptions | What is thrown, when, and how to catch it. |
use InitPHP\Upload\Upload;
use InitPHP\Upload\File;
use InitPHP\Upload\Adapters\LocalAdapter;
$upload = new Upload(new LocalAdapter([
'dir' => __DIR__ . '/uploads/',
'url' => 'https://example.com/uploads/',
]));
foreach (File::setPost('photos') as $file) {
$stored = $upload->setFile($file)->to('2026/06');
if ($stored !== false) {
echo $stored->getURL(); // https://example.com/uploads/2026/06/<name>
}
}File— a value object describing one file to upload. Build a list from$_FILESwithFile::setPost(), or wrap an existing path withFile::setPath().- Adapter — a storage backend (
LocalAdapter,FTPAdapter,S3Adapter). It takescredentials(where to store) andoptions(what to allow). Upload— a thin decorator over an adapter. It is the object you callsetFile()andto()on.$target— the optional destination path/key prefix passed toto(), with the same meaning in every adapter.
- PHP 8.0 or newer
ext-fileinfo(real MIME detection)ext-ftpfor the FTP adapter;aws/aws-sdk-phpfor the S3 adapter