0

I want to ask about how to get the file path of the file i want to upload from file input, the code is like this

<?= $form->field($model, 'file')->fileInput() ?>

the problem is i want to automatically send the file as attachment of email without uploading the file to hosting, which required the path of local file

 ->attach('C:/Users/User/Downloads/file/file.pdf')

I want to get file path like

'C:/Users/User/Downloads/file/file.pdf'

is it possible? or there is another method to fix my problem? Thanks in advance

unknown.person
  • 135
  • 2
  • 11

1 Answers1

1
Check yii2 doc. [http://www.yiiframework.com/doc-2.0/yii-web-uploadedfile.html]
if (Yii::$app->request->isPost) {
       $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
       $tempFilePath = $model->imageFile->tempName;
       //Send Email.
    }
Kalu
  • 561
  • 2
  • 7
  • sorry for late update, it work, but i already used some code from this question https://stackoverflow.com/questions/46660315/yii2-form-to-send-attachment ,thanks – unknown.person Oct 16 '17 at 02:20