-
Notifications
You must be signed in to change notification settings - Fork 16
Working with Pimf_Util_Uploaded
g.krsteski edited this page Jun 3, 2014
·
6 revisions
Gives a methods to act in a secure way with a file/s uploaded through a form.
Create a file instance.
$uploaded = new Pimf\Util\Uploaded(
$_FILES['tmp_name'], $_FILES['name'],
$_FILES['type'], $_FILES['size'], $_FILES['error']
);
Create an instance using the factory-class for more security.
$uploaded = Pimf\Util\Uploaded\Factory::get($_FILES);
Let Pimf\Util\Uploaded work for you.
if ($uploaded instanceof Pimf\Util\Uploaded) {
if(in_array(
$upload->getClientMimeType(),
array('image/gif', 'image/jpg'))
) {
try {
$uploaded->move(
'path/to/your/images/dir', $upload->getClientOriginalName()
);
} catch (RuntimeException $e) {
//error!!!
}
}
}