G
G
goldwizard132017-05-12 16:28:17
Yii
goldwizard13, 2017-05-12 16:28:17

How to attach uploaded files to a message?

In the feedback form, I upload files using CUploadedFile
How to attach uploaded files to a message?
In the controller I send a letter

if ($model->validate()) {
        
        //Так пытаюсь загрузить файлы
        
 if($filez=$this->uploadMultifile($model,'attachments','/tmp/attachments/'))
   {
   $model->attachments=implode(",", $filez);
   }
        
      //Как прикрепить файлы к сообщению
    
            $headers = "From: $email";
                    $message = '<p>Э-почта: ' . $model->email . '</p>'
                            . '<p>Имя: ' . $model->name . '</p>'
                            . '<p>Сообщение: ' . $model->body . '</p>';
          $message. =	'';//Как прикрепить файлы к сообщению
                   
           // ... отправка сообщения администратору ...
          mail('[email protected]', $subject, $message, $headers);
                    
                    echo CActiveForm::validate($model);
                    Yii::app()->end();
                } else {
                    echo CActiveForm::validate($model);
                }
            }
            Yii::app()->end();
        } else {
            throw new CHttpException(404, 'Указанная запись не найдена');
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-05-12
@goldwizard13

Create a multipart email, where one of the parts is a BASE64 encoded file.
https://habrahabr.ru/sandbox/48759/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question