# In Cakephp 3.6 I cannot upload an image through a form

**URL:** <https://discourse.cakephp.org/t/in-cakephp-3-6-i-cannot-upload-an-image-through-a-form/5774>\
**Category:** Need Help\
**Created:** [March 12, 2019, 12:55pm UTC](https://discourse.cakephp.org/t/in-cakephp-3-6-i-cannot-upload-an-image-through-a-form/5774 "2019-03-12T12:55:28Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![bichomen](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/bichomen/32/1070_2.png) [@bichomen](https://discourse.cakephp.org/u/bichomen)\
**Post date:** [March 14, 2019, 11:00am UTC](https://discourse.cakephp.org/t/in-cakephp-3-6-i-cannot-upload-an-image-through-a-form/5774/13 "2019-03-14T11:00:23Z")

</div>

He does the same thing. But I’ve noticed that it doesn’t get the **event.target.files** so it doesn’t make a `var data = new FormData(this);` but if a `var data = $(this).serialize();` ignoring the file.

```
if(event.target.files) {
      	       var data = new FormData(this);
	       contentType = false;
		processData = false;
	}
	else {
	 	var data = $(this).serialize();
	}
```

---

_[View the full topic](https://discourse.cakephp.org/t/in-cakephp-3-6-i-cannot-upload-an-image-through-a-form/5774)._
