2012-07-05 4 views
0

beforeSave()를 사용하여 업로드 된 파일의 이름을 바꿉니다. 폴더에 저장되기 전에 이름이 바뀌지 않습니다. 그것은 업로드 된 파일과 동일한 이름을 가지고 있습니다 .Iam은 파일 업로드를 위해 확장 EAjaxUpload를 사용합니다. 아무도 내가 잘못한 곳에서 나를 도울 수 있습니까? 그리고 나는 창문에서 일하고 있습니다. 모델에서beforeSave() yii (php)에서 파일의 이름을 바꾸려면

(AttachResume) : - : http://www.yiiframework.com/extension/eajaxupload/ 그게

protected function beforeSave() 
{ 
          $path='C:\\wamp\\www\\Myapp\\Resumes\\'; 
         $uid=$_POST['AttachResume']['User_id']; 
         //var_dump($this->User_id); exit(); 
         $file=$_POST['AttachResume']['ResumeName']; 
         //var_dump($this->ResumeName); exit(); 
         $temp = $path.$file; 
         $newname=$uid.$file; 
         if(file_exists($temp)==true) 
         { 
          rename($temp, $path.$newname); 

         } 
       return parent::beforeSave(); 

    } 
Controller:- 
public function actionIndex() 
{ 
    $model=new AttachResume; 
    if(isset($_POST['AttachResume'])) 
     { 

     $model->User_id=$_POST['AttachResume']['User_id']; 
    $model->ResumeName=$_POST['AttachResume']['ResumeName']; 
    $model->save(); 

     } 
     $this->render('index',array('model'=>$model)); 
    } 

MYAPP가 aplication.Resume입니다이 확장을 사용 감사

+0

누군가가 친절하게 나를 도와. – DpGp

+0

당신은 여전히 ​​해결책을 찾고 있습니까? –

+0

예 메신저 아직도 솔루션을 찾고 .. 당신은 내게 무슨 wnt 잘못 말해 줄 수 있니? – DpGp

답변

0

내가 문서를 저장해야 그 아래 폴더입니다 사용 가능한 최상의 확장자

업로드 할 파일의 이름을 바꾸려면 다음 줄을 추가하십시오. rename ($ folder. $ result [ 'filename'], $ folder. newfilename "); 벤에

감사 :이 링크를 발견 해결 방법 : 내가 프레임 워크를 YII 잘못 somewrhere.I에게 새로운 갔을 경우 How to use xupload with Yii

관련 문제