The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Accessing FormData data from $request

John Smith's Avatar

John Smith

04 Feb, 2016 04:37 PM

I'm trying to upload files via AJAX call to a route.

The file is uploaded via FormData object embedded into the ajax call like so :

method: 'POST',
data: formdata
... })

I can access the non 'file' data, such as simple key, value pairs using ' $request->getParsedBody() ' but cannot access the file, in this case an image.

And I know that the image file is being sent because when I check the 'network' information in my developer console, the file is part of the request body.

Also the $_FILES array is empty. $_POST array doesn't contain files.

  1. 1 Posted by John Smith on 05 Feb, 2016 11:54 PM

    John Smith's Avatar

    Answer to myself:


  2. 2 Posted by alan on 27 Mar, 2020 02:15 PM

    alan's Avatar

    Thank you!

  3. Josh Lockhart closed this discussion on 12 Feb, 2021 07:37 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac