2017-10-06 6 views
0

업로드 된 로컬 파일의 파일 경로를 얻을 yii2 코드는 문제는 내가 원하는이며이나는 내가 파일 입력에서 업로드 할 파일의 파일 경로를 얻는 방법에 대해 물어보고 싶은

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

같다 자동으로 내가

'C:/Users/User/Downloads/file/file.pdf' 
같은 파일 경로를 얻으려면

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

로컬 파일의 경로를 요구하는 호스팅에 파일을 업로드하지 않고 이메일의 첨부 파일로 파일을 전송하기

가능합니까? 또는 내 문제를 해결할 다른 방법이 있습니까? 사전

+0

에서 덕분에이 비슷한 질문을 살펴보십시오 - https://stackoverflow.com/questions/857618/javascript-how-to-extract-filename-from-a-file-input-control –

+0

알았어, 자바 스크립트로 할려고하면 나중에 결과를 업데이트 할 것이다 –

+0

yii2 doc : http : // www.yiiframework.com/doc-2.0/yii-web-uploadedfile.html을 확인하십시오. – Kalu

답변

0
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. 
    } 
+0

늦은 업데이 트에 대한 미안 해요, 작동하지만, 이미이 질문에서 일부 코드를 사용 https://stackoverflow.com/questions/46660315/yii2-form-to-send-attachment ,감사 –