0

I'm adding RESTFull api to my site, and i need to update my tools, where are pictures witch need to be updated too. My problem is like that for PUT request

/**
* @Rest\Put("/tools/{id}")
* 
* @param Request $request
*/
public function editToolAction($id, Request $request)

symfony is only parsing data with Content_type application/x-www-form-urlencoded, so i can get it from request, and this is working for strings etc.

$parameters = $request->request->all();

but to send files i need header to be:

content-type:"multipart/form-data; boundary....

$parameters = $request->request->all();
$files = $request->files->all();

but for multipart header i'm getting nulls for both parameters and files

for @Rest\POST this is working perfectly

im not working on client side so i can't change request from PUT to POST, any ideas how to fix it ?

site is using symfony 3.4. , php 7.2. , FOSRestBundle, FOSOAuthBundle,.... to check if it is working Postman was used

Edgarth
  • 124
  • 1
  • 12

1 Answers1

0

PHP will automatically parse application/form-data for you and place the result in $_FILES. Symfony likely just reads from that super global to populate the result of the ->files() function.

However, PHP will only do this for POST requests. Since you're using PUT, PHP won't parse it, and Symfony will likely not expose it.

If symfony doesn't have a userland implementation of an application/form-data parser, you should find one on composer.

Evert
  • 93,428
  • 18
  • 118
  • 189