Using file objects in a mail message (Dashboard Single Page)
Permalink 1 user found helpful
I try to attach a file object to the
I have included the following in the form of my view:
Then I submit my form back to the controller. There (BTW all other form fields arrive in the contorller as expected) I do:
which returns a File object. Should do, because when I do it gives me the correct path to the chosen file.
So far so good. BUT when I try to send a mail with exactly that file object attached: the following error occurs: which apparently comes from this class method: which apparently wants a file object as param, which I think I gave it, weren't I?
Why my file object becomes a FileVersion, which, as I see by myself, hasn't got a method getPath().
So after hours of trying around with File & FileVersion/.. I'd be glad to get some help please!
How do I get the correct file object, which I have to, apparently , take out of the last Version of this file?
$mail = Loader::helper('mail');
I have included the following in the form of my view:
$f = new Concrete\Core\Application\Service\FileManager(); //... echo $f->file('file', 'test', 'pls choose');
Then I submit my form back to the controller. There (BTW all other form fields arrive in the contorller as expected) I do:
$files = $this->post('test'); $file = \File::getByID($files);
which returns a File object. Should do, because when I do
$file = \File::getRelativePathFromID($files);
So far so good. BUT when I try to send a mail with exactly that file object attached:
$mail = Loader::helper('mail'); $mail->setTesting(false); $mail->setSubject('test-subject'); $mail->to($this->post('uEmail')); //... $attach = $mail->addAttachment($file); $attach->filename = 'tttt'; $mail->sendMail();
call_user_func_array() expects parameter 1 to be a valid callback, class 'Concrete\Core\File\Version' does not have a method 'getPath'
namespace Concrete\Core\Mail; //... class Service { //... /** * Add attachment to send with an email. * //... example * * @param File $fob File to attach * @return StdClass Pointer to the attachment */ public function addAttachment(\Concrete\Core\File\File $fob) { // @TODO make this work with the File Storage Locations
Viewing 15 lines of 19 lines. View entire code block.
Why my file object becomes a FileVersion, which, as I see by myself, hasn't got a method getPath().
So after hours of trying around with File & FileVersion/.. I'd be glad to get some help please!
How do I get the correct file object, which I have to, apparently , take out of the last Version of this file?
We'll have to either patch this by ourselfs or wait until version 7.4 lands.
Thx to SO user Korvin Szanto.
I should really read the github bug messages!!!