spadeX
November 18, 2022, 5:22am
1
$name = $attachment->getClientFilename();
$type = $attachment->getClientMediaType();
$size = $attachment->getSize();
$tmpName = $attachment->getStream()->getMetadata(‘uri’);
$error = $attachment->getError();
getClientFilename() function is undefined. cakephp4.3
Make sure your submitting form is of type file
See Form - 4.x
echo $this->Form->create($entity, ['type' => 'file']);
// or if you don't have an entity form
echo $this->Form->create(null, ['type' => 'file']);
Check the type of your submitted field in your controller.
$file = $this->getRequest()->getData('myfile');
pr($file);
if your file upload field is
echo $this->Form->control('myfile', ['type' => 'file']);
The file type of $file
should be \Laminas\Diactoros\UploadedFile
if its still not working (and you get an array instead of an object) please check that your App.uploadedFilesAsObjects
config value is NOT set to false
1 Like