I am trying to make my Symfony2 program only accept PDF-files. 
In the entity class I have: 

```
/**
 * File
 *
 * @var File
 *
 * @Assert\File(
 *      maxSize = "5M",
 *      mimeTypes = {"application/pdf", "application/x-pdf"},
 *      maxSizeMessage = "The maxmimum allowed file size is 5M.",
 *      mimeTypesMessage = "Please upload a valid PDF"
 * )
 */
protected $file;

```

The question is why I still can upload other files. I am currently uploading through REST API. 

The code: 

```
    public function postFileAction(Request $request){

    $name = $request->get('name');
    $path = $request->get('path');
    $file = $request->files->get('file');

    $filesTest = new FilesTest();
    $filesTest->setName($name);
    $filesTest->setFile($file);;

    $manager = $this->getDoctrine()->getManager();
    $manager->persist($filesTest);
    $manager->flush();
    }

```

I am new at symfony2 so I might have misunderstood how to handle this. Does anyone have any suggestions?