Skip to content

Instantly share code, notes, and snippets.

@toolpixx
Created January 19, 2015 15:12
Show Gist options
  • Save toolpixx/504558a3e0e3fbc9738e to your computer and use it in GitHub Desktop.
Save toolpixx/504558a3e0e3fbc9738e to your computer and use it in GitHub Desktop.
Simple move attachment with symfony2
...other stuff before....
/**
*
* use Symfony\Component\HttpFoundation\File\UploadedFile as UploadedFile;
*
* $message is instanceof \Swift_Message::newInstance()
* $enquiry is instanceof EnquiryEntity
* $enquiry->getAttachment() is the file-attribute for upload
*
*/
if ($enquiry->getAttachment() instanceof UploadedFile) {
$enquiry->getAttachment()->move(
__DIR__.'/../../../../web/uploads',
$enquiry->getAttachment()->getClientOriginalName()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment