You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 5, 2024. It is now read-only.
When the HTML form is submitted, the server-side PHP code can validate and upload the file like this:
<?php$storage = new \Upload\Storage\FileSystem('/path/to/directory');
$file = new \Upload\File('foo', $storage);
// Optionally you can rename the file on upload$new_filename = uniqid();
$file->setName($new_filename);
// Validate file upload// MimeType List => https://www.iana.org/assignments/media-types/media-types.xhtml$file->addValidations(array(
// Ensure file is of type "image/png"new \Upload\Validation\Mimetype('image/png'),
//You can also add multi mimetype validation//new \Upload\Validation\Mimetype(array('image/png', 'image/gif'))// Ensure file is no larger than 5M (use "B", "K", M", or "G")new \Upload\Validation\Size('5M')
));
// Access data about the file that has been uploaded$data = array(
'name' => $file->getNameWithExtension(),
'extension' => $file->getExtension(),
'mime' => $file->getMimetype(),
'size' => $file->getSize(),
'md5' => $file->getMd5(),
'dimensions' => $file->getDimensions()
);
// Try to upload filetry {
// Success!$file->upload();
} catch (\Exception$e) {
// Fail!$errors = $file->getErrors();
}