I have a really simple controller (with FOSRESTBundle)
/**
* @Rest\Post("/posts/{id}/attachments", name="api_create_attachment", requirements={"pId"="\d+"})
* @Rest\View()
*/
public function createAttachments(Request $request)
{
/** @var UploadedFile $attachment */
$attachment = $request->files->get('file');
return $attachment->getFilename();
}
I just want to dump the filename from POST request of /api/posts/{id}/attachments. I use Postman with the Content-Type: multipart/form-data
header for allowing the file to be send.
Now, i have two files (pp.jpg: 163kb and para.jpg: 358kb). When i try to send the request with pp.jpg it's working perfectly and it return "phpyl3yNE" (the filename). But now, when i'm trying with para.jpg which is not really different, it return me an error "Call to a member function getFilename() on null"
. And it's the same with many differents files ! I can't figure out why ... i use the symfony serve
command for the server and from phpinfo, post_max_size
is set to 8M and upload_max_filesize
is set to 2M.
I'm stuck at this point .. I can't figure out why it return me null ...
Thank you, have a nice day !