1
我对Yii相当陌生。我使用YiiMail扩展来发送邮件。我能够发送邮件,但无法发送附件。添加附件在Yii发送邮件
我已经得到了下面的代码,但现在知道那个“tempName”是什么意思?
mycontroller-
$uploadedFile = CUploadedFile::getInstanceByName('filename'); // get the CUploadedFile
$uploadedFileName = $uploadedFile->tempName; // will be something like 'myfile.jpg'
$swiftAttachment = Swift_Attachment::fromPath($uploadedFile); // create a Swift Attachment
$this->email->attach($swiftAttachment); // now attach the correct type
好感谢!但它给我一个错误,因为“尝试获取非对象的属性”指向上面的代码中的第二行。 – user
所以这意味着可能没有上传文件,所以你应该检查上传是否正确 – Asped
它与我上面写的相同的代码,我不明白我要去哪里错 – user