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:
Enjoy!
Im trying to use this gist but __sleep magic function doesnt works in my entity.
I dont know what happens.
Do you have all serializable fields marked as “protected”? Private or public fields will be ignored.
OMG, that’s save my life !!
Hi, I’m a beginner in laravel (it use Symfony component), and i have the same problem , how can i resolve it ?
Have you tried the solution above?
yes I tried, but I do not know how to implement.