-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
| Requirement | Needed for |
|---|---|
| PHP 8.0+ | The whole library. |
ext-fileinfo |
Detecting the real MIME type of a file (used by validation and File::getRealMimeType()). Bundled with most PHP builds. |
ext-ftp |
Only the FTP adapter. |
aws/aws-sdk-php |
Only the S3 adapter. |
The core package has no runtime Composer dependencies. The S3 SDK is a suggested dependency you install only if you use the S3 adapter.
composer require initphp/uploadcomposer require aws/aws-sdk-phpIf you construct an S3Adapter without the SDK installed, the
constructor throws an UnsupportedException:
AWS S3 SDK must be installed to use this adapter. Try running "composer require aws/aws-sdk-php".
Most distributions ship it. Check with:
php -m | grep ftpConstructing an FTPAdapter without it throws an
UnsupportedException:
FTP adapter cannot be used on your server.
<?php
require __DIR__ . '/vendor/autoload.php';
use InitPHP\Upload\Upload;
use InitPHP\Upload\Adapters\LocalAdapter;
$upload = new Upload(new LocalAdapter([
'dir' => sys_get_temp_dir(),
'url' => 'https://example.test',
]));
echo get_class($upload); // InitPHP\Upload\UploadIf that runs without error, you are ready for the Quick Start.
initphp/upload follows Semantic Versioning. Pin a
constraint that allows compatible updates:
{
"require": {
"initphp/upload": "^1.0"
}
}Everything lives under the InitPHP\Upload namespace:
| Class | Namespace |
|---|---|
Upload |
InitPHP\Upload\Upload |
File |
InitPHP\Upload\File |
LocalAdapter |
InitPHP\Upload\Adapters\LocalAdapter |
FTPAdapter |
InitPHP\Upload\Adapters\FTPAdapter |
S3Adapter |
InitPHP\Upload\Adapters\S3Adapter |
UploadAdapterInterface |
InitPHP\Upload\Interfaces\UploadAdapterInterface |
UploadException |
InitPHP\Upload\Exceptions\UploadException |
UnsupportedException |
InitPHP\Upload\Exceptions\UnsupportedException |
UploadInvalidArgumentException |
InitPHP\Upload\Exceptions\UploadInvalidArgumentException |
initphp/upload · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Reference
Adapters
Practical Guides
Other