# File upload not wroking

**URL:** <https://discourse.cakephp.org/t/file-upload-not-wroking/10771>\
**Category:** Need Help\
**Tags:** help\
**Created:** [November 18, 2022, 5:22am UTC](https://discourse.cakephp.org/t/file-upload-not-wroking/10771 "2022-11-18T05:22:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)\
**Post date:** [November 18, 2022, 5:22am UTC](https://discourse.cakephp.org/t/file-upload-not-wroking/10771/1 "2022-11-18T05:22:55Z")

</div>

$name = $attachment-\>getClientFilename();  
$type = $attachment-\>getClientMediaType();  
$size = $attachment-\>getSize();  
$tmpName = $attachment-\>getStream()-\>getMetadata(‘uri’);  
$error = $attachment-\>getError();

getClientFilename() function is undefined. cakephp4.3

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [November 18, 2022, 11:20am UTC](https://discourse.cakephp.org/t/file-upload-not-wroking/10771/2 "2022-11-18T11:20:16Z")

</div>

1. Make sure your submitting form is of type `file` See [Form - 4.x](https://book.cakephp.org/4/en/views/helpers/form.html#changing-the-http-method-for-a-form)

```auto
echo $this->Form->create($entity, ['type' => 'file']);
// or if you don't have an entity form
echo $this->Form->create(null, ['type' => 'file']);

```

1. Check the type of your submitted field in your controller.

```auto
$file = $this->getRequest()->getData('myfile');
pr($file);

```

if your file upload field is

```auto
echo $this->Form->control('myfile', ['type' => 'file']);

```

The file type of `$file` should be `\Laminas\Diactoros\UploadedFile`

1. 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`
