Last active
January 25, 2017 11:03
-
-
Save MaximStrutinskiy/51cb74b49fd2db40583b96fa3f8a1825 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if form is mapped => false; | |
$img = $form->get('img')->getData(); | |
//if form is mapped => true | |
$img = $user->getImg(); | |
if ($img !== NULL) { | |
// Generate a unique name for the file before saving it | |
$fileName = md5(uniqid()) . '.' . $img->getExtension(); | |
// Move the file to the directory where brochures are stored | |
$img->move( | |
$this->getParameter('user_images'), | |
$fileName | |
); | |
// Update the 'img' property to store the img file name | |
// instead of its contents | |
$user->setImg($fileName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment