Last active
February 27, 2019 18:50
-
-
Save toolpixx/1b4b02d687aeb9993be9 to your computer and use it in GitHub Desktop.
Simple attachment with symfony2 and swiftmailer without move attachment before...
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
...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) { | |
$message->attach( | |
\Swift_Attachment::fromPath( | |
$enquiry->getAttachment() | |
) | |
->setFilename( | |
$enquiry->getAttachment()->getClientOriginalName() | |
) | |
->setContentType( | |
$enquiry->getAttachment()->getClientMimeType() | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment