Serialization of UploadedFile is not allowed fix
If you are doing file uploads in Symfony2 with help from the cookbook tutorial you might have ran into the following error:
Serialization of ‘Symfony\Component\HttpFoundation\File\UploadedFile’ is not allowed.
The solution I came up with involves excluding the public $file field from serialization. That way we bypass the exception.
One catch, though: this will exclude all fields that are not protected.
Add the following function to your entity: