I am trying to upload image using zend form class and my current input filter is this
$inputFilter->add([
"name" => "ImageLogo",
"required" => false,
"validators" => [
[
"name" => "FileMimeType",
"options" => [
"mimeType" => [ "image/jpeg", "image/png" ],
],
],
[
"name" => "FileIsImage",
],
],
"filters" => [
[
"name" => "FileRenameUpload",
"options" => [
"target" => getcwd() . "/public/uploads/logos",
"useUploadName" => true,
"useUploadExtension" => true,
"overwrite" => true,
"randomize" => true,
],
],
],
]);
It uploads perfectly, but I have some parts that I couldn't able to modify.
First, I would like $entity
's Id to be prepended before uploading. Something like, $entity->getId() . $fileName
(Confusion: what if I'm adding a new entity. There won't be id)
Second, how would I get file name in controller after validating form. This
if ($form->isValid()) {
print_r($form->getData());exit();
}
Shows old name.