php - Symfony2 controller store file in database -


i've been trying store binary file in database using controller. have entity blob field. how can read uploaded file, binary data , store in blob field?

so far have code:

  public function postpictureaction($slug, request $request)   {     return $request->files;   } 

and this:

  {      "parameters": {         "picture": {             "test": false,             "original_name": "untitled diagram.png",             "mime_type": "image/png",             "size": 13423,             "error": 0         }     },     "file_keys": [         "error",         "name",         "size",         "tmp_name",         "type"     ] } 

so file seems uploaded fine, now, it? how can read it?

this code returns file's mime type:

$picture->settype($file->getmimetype()); 

but intuition, since didn't find documentation on "file" class. there such documentation?

the path taking out of symfony2 going path use native php, generate form 'file' type create upload file returned uploadfile object. if want store file blob in database , not using upload folder suggested in docs : http://api.symfony.com/2.0/symfony/component/httpfoundation/file/uploadedfile.html

you can use :

public function upload(){       $file = $request->files->get('picture');        $entity->setbinary(file_get_contents($file)); //binary property of entity class blob      $entity_manager->persist($entity);     $entity_manager->flush();  }