# Cannot get uploaded files on Cakephp 4

**URL:** <https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927>\
**Category:** Need Help\
**Created:** [January 30, 2021, 7:11am UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927 "2021-01-30T07:11:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marko](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@marko](https://discourse.cakephp.org/u/marko)\
**Post date:** [January 30, 2021, 7:11am UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/1 "2021-01-30T07:11:35Z")

</div>

What am I missing when I try to get uploaded files in my controller? If I debug PHP native $\_FILES “superglobal” I can get all the upload file information there. There is no error.

But in CakePHP post data I get empty data in posted “file” field. It’s mind boggling and I cannot find out what to debug… Is there some logic conditions when Cake discards file input (but it is fine on PHP side)?

I may need to use PHP $\_FILES soon (build my own logic) but there should be fine functions in CakePHP for this so it is a shame…

---

<div class="post-metadata">

**Author:** ![Salines](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/salines/32/3420_2.png) [@Salines](https://discourse.cakephp.org/u/Salines)\
**Post date:** [February 1, 2021, 8:22am UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/2 "2021-02-01T08:22:39Z")

</div>

Check this

[https://book.cakephp.org/4/en/controllers/request-response.html#uploaded-files](https://book.cakephp.org/4/en/controllers/request-response.html#uploaded-files)

---

<div class="post-metadata">

**Author:** ![marko](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@marko](https://discourse.cakephp.org/u/marko)\
**Post date:** [February 1, 2021, 3:00pm UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/3 "2021-02-01T15:00:53Z")

</div>

Thanks, I have read that. But the problem is that file information is empty in data… $\_FILES works as I described earlier. What might be the reason?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 1, 2021, 6:15pm UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/4 "2021-02-01T18:15:24Z")

</div>

`$request->getUploadedFiles()` is returning nothing? I can’t remember if maybe Cake is more strict about what form types it will extract files from than the HTTP spec. Remember that Cake code is just PHP code, so you can look at what `getUploadedFiles` returns, then look for where that gets initialized, and see what conditions there may be around that. It’s all debuggable!

---

<div class="post-metadata">

**Author:** ![Hareshpatel](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hareshpatel](https://discourse.cakephp.org/u/Hareshpatel)\
**Post date:** [February 2, 2021, 12:44pm UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/5 "2021-02-02T12:44:57Z")

</div>

Make sure that you have include enctype attribute into form declaration like below

`echo $this->Form->create(null, ['id'=>'myForm','role' => 'form','enctype'=>'multipart/form-data']);`

---

<div class="post-metadata">

**Author:** ![marko](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@marko](https://discourse.cakephp.org/u/marko)\
**Post date:** [February 3, 2021, 6:27am UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/6 "2021-02-03T06:27:30Z")

</div>

@Hareshpatel Yes, thanks. I have this. And PHP side works fine.

@Zuluru, thanks! I’ll do that - I’m sure debugging will reveal something… But it has to wait when I have more time for that…

---

<div class="post-metadata">

**Author:** ![philhoa](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@philhoa](https://discourse.cakephp.org/u/philhoa)\
**Post date:** [October 14, 2022, 3:49am UTC](https://discourse.cakephp.org/t/cannot-get-uploaded-files-on-cakephp-4/8927/7 "2022-10-14T03:49:16Z")

</div>

Dear Marco,  
have you resolved you issue?  
I am expereienced the same.  
Regards.
