2012-07-23 2 views
0

다음 젠드 프레임 워크 양식을 작동하지 않는 : 나는 양식이 제대로 작동 코드에서이 줄을 제거하면Zend_Form_Element_File가 제대로 작동하지 않습니다

->setDestination('/data/uploads') 

:

<?php 

class Application_Form_Auth extends Zend_Form 
{ 

    public function init() 
    { 
     $this->setAttrib('enctype', 'multipart/form-data'); 
     $this->setMethod('post'); 

     $username = $this->createElement('text','username'); 
     $username->setLabel('Username:') 
       ->setAttrib('size',10); 

     $password = $this->createElement('password','password'); 
     $password->setLabel('Password') 
       ->setAttrib('size',10); 

     $file = new Zend_Form_Element_File('file'); 
     $file->setLabel('File') 
      ->setDestination('/data/uploads') 
      ->setRequired(true); 

     $reg = $this->createElement('submit','submit'); 
     $reg->setLabel('save');    

     $this->addElements(array(
      $username, 
      $password, 
      $file, 
      $reg 
     )); 

     return $this; 
    } 
} 
?> 

문제에 있습니다. /data/uploads에 업로드 폴더가 있고 디렉토리에 777으로 설정된 권한이 있습니다. 이 문제를 어떻게 해결할 수 있습니까? 감사합니다

+2

'data' 폴더가 실제로 서버의 루트에 있거나 응용 프로그램 디렉토리에 있습니까? 경로를 잘못 지정했다고 생각합니다. 'APPLICATION_PATH를 시도하십시오. '/ data/uploads'를 대신 사용하십시오. – drew010

답변

1

도메인을 사용하고 있습니까 (Out out with localhost). 그렇다면 데이터/업로드를 사용해야합니다. 데이터 디렉토리는 공용 디렉토리에 있어야합니다. 도메인이 있다면 baseUrl을 사용하여 대상 경로를 사용해야합니다.

관련 문제