- Revert removal of
\GravityPdf\Upload\File::__call()
magic method in 2.0.0, restoring API functionality to match v1 - Add
setNameWithExtension()
method to\GravityPdf\Upload\FileInfoInterface
- Change type signature
\GravityPdf\Upload\FileInfoInterface::setName(string $name)
- Change type signature
\GravityPdf\Upload\FileInfoInterface::setExtension(string $extension)
- Remove
\GravityPdf\Upload\Validation\Dimensions
validation class
- PHP 7.3+ (previously PHP5.3+)
- Namespace Change:
\Upload
->\GravityPdf\Upload
- Sanitize Filename and Extension: replace invalid/unsafe/reserved characters/words, trim, prevent < 255 byte filenames. See the unit tests for the expected transformations.
- Remove
\GravityPdf\Upload\File::__call()
magic method which would call the underlyingFileInfoInterface
object(s) and return the result as a string or array. Useforeach($file as FileInfoInterface $fileInfo) { ... }
instead. - Changed return value of
\GravityPdf\Upload\Storage\FileSystem::upload()
to the destination file pathstring
(previouslyvoid
) - Strict type support added
- Replace
\Upload\Exception\UploadException
with\GravityPdf\Upload\Excelption
\GravityPdf\Upload\File
no longer extends\SplFileInfo
- Signature of
\GravityPdf\Upload\File::__construct()
changed to__construct(string $key, \GravityPdf\Upload\StorageInterface $storage)
- Signature of
\GravityPdf\Upload\File::addValidations()
changed toaddValidations(array $validations)
. Use newaddValidation(\GravityPdf\Upload\ValidationInterface $validation)
method to add single validation. \GravityPdf\Upload\File::validate()
was replaced by\GravityPdf\Upload\File::isValid()
- Signature of
\GravityPdf\Upload\File::upload($newName = null)
changed toupload()
. Use\GravityPdf\Upload\File::setName(string $name)
or\GravityPdf\Upload\File::setNameWithExtension(string $name)
before callingupload()
to change the file name. \Upload\Storage\Base
has been removed and\GravityPdf\Upload\Storage\FileSystem
instead implements\GravityPdf\Upload\StorageInterface
- Signature of
\Upload\Storage\FileSystem::upload(\Upload\File $file, $newName = null)
changed to\GravityPdf\Upload\Storage\FileSystem::upload(\GravityPdf\Upload\FileInfoInterface $fileInfo)
\Upload\Validation\Base
has been removed and\GravityPdf\Upload\Validation/*
classes instead implements\GravityPdf\Upload\ValidationInterface
- Classes that implement
\GravityPdf\Upload\ValidationInterface
must havevalidate
method with the signaturevalidate(\Upload\FileInfoInterface $fileInfo)
and this method should throw the exception\GravityPdf\Upload\Exception
if the file has failed validation
- Support for UTF-8 Filenames
- Enhanced file name and extension sanitizing (you still need to escape HTML on output or when inserting into database)
- Added
\GravityPdf\Upload\FileInfo::setNameWithExtension(string $name)
(instead of usingsetName()
andsetExtension()
separately) - Added
\GravityPdf\Upload\Storage\FileSystem::getDirectory()
to return directory that has been set - Added
beforeValidation(callable $callable)
,afterValidation(callable $callable)
,beforeUpload(callable $callable)
, andafterUpload(callable $callable)
to\GravityPdf\Upload\File
. The callable will receive a\GravityPdf\Upload\FileInfoInterface
object as the first parameter. \GravityPdf\Upload\File
implements\ArrayAccess, \IteratorAggregate, \Countable
which allows you to treatFile
as an array and access the underlying\GravityPdf\Upload\FileInfo
objects to get info about each individual file for the current$key
. This is useful if your file upload HTML field accepts multiple files.- Added
\GravityPdf\Upload\FileInfoInterface
and\GravityPdf\Upload\FileInfo
objects to represent each individual image. The methods include:getPathname()
getName()
setName(string $name)
getExtension()
setExtension(string $extension)
getNameWithExtension()
setNameWithExtension(string $filename)
getMimetype()
getSize()
getMd5()
getDimensions()
isUploadedFile()
- Resolved PHP 8.1 warnings