Slim 4 file upload

Hello,

I upgraded from slim 3 to 4. I made an rest-api for my frontend with angular 8. On the frontend I use
FormData to upload the image(https://academind.com/learn/angular/snippets/angular-image-upload-made-easy/). For slim 3 this worked. In Slim 4 $request->getUploadedFiles() returns an empty array. I read https://www.slimframework.com/docs/v4/cookbook/uploading-files.html and checked if there is a header “Content-Type:multipart/form-data”. The actual stream is in the request-payload. I surely do something wrong or forgot something. Has anyone some advice or tip?

thanks beforehand!

Coen Dunnink
The Netherlands

Hello,

I also checked $_FILES and this is empty. The php.ini says " file uploads" = On

Hi, Have you tried looking at this section in the documentation regarding uploading?

http://www.slimframework.com/docs/v4/objects/request.html#uploaded-files

http://www.slimframework.com/docs/v4/cookbook/uploading-files.html

Hello,

I send a header application/json with the POST. This caused the image to be in the body. Thus no files($_FILES) were found.
Thanks for the help!

No problem. Glad it works :stuck_out_tongue_winking_eye: