PSR 17: UploadedFileFactory Example
Terry L edited this page
Jun 21, 2020
Clone this wiki locally
*The underlying stream representing the uploaded file content.
= nullThe size of the file in bytes.
= 0The PHP file upload error.
= nullThe filename as provided by the client, if any.
= nullThe media type as provided by the client, if any.
$uploadedFileFactory = new UploadedFileFactory(); $sourcePath = BOOTSTRAP_DIR . '/sample/shieldon_logo.png'; $targetPath = STORAGE_DIR . '/images/shieldon_logo.png'; $streamFactory = new StreamFactory(); $uploadedFileFactory = new UploadedFileFactory(); $stream = $streamFactory->createStreamFromFile($sourcePath); $uploadedFile = $uploadedFileFactory->createUploadedFile($stream); // Move file from $sourcePath to $targetPath. $uploadedFile->moveTo($targetPath);