-
Notifications
You must be signed in to change notification settings - Fork 1
UploadedFile: moveTo Example
Terry L edited this page Jun 20, 2020
·
2 revisions
Shieldon\Psr7\UploadedFile
Move the uploaded file to a new location.
-
param
string
targetPath*
Path to which to move the uploaded file.
$stream = new Stream(
fopen(BOOTSTRAP_DIR . '/sample/shieldon_logo.png', 'r+')
);
$uploadedFile = new UploadedFile($stream);
$uploadedFile->moveTo('/home/terrylin/public/image_cache/shieldon_logo_png');
if (
file_exists('/home/terrylin/public/image_cache/shieldon_logo_png') &&
! file_exists(BOOTSTRAP_DIR . '/sample/shieldon_logo.png')
) {
echo 'File has been moved to the new place.';
} else {
echo 'Cannot move file.';
}
// Outputs: File has been moved to the new place.
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.