必須是一些簡單的解決辦法,但作爲初學者,我已經花了2天的時間來了解。我有一個簡單的表單(「enctype =」multipart/form-data「),輸入的文本和文件很少,我不能得到什麼錯誤,我可以通過getParameter()獲取用戶的文本數據,但無法獲取文件。的GetFiles()我是在Ubuntu 11.04 PHP5.3Symfony 1.4無法獲得提交的文件
代碼:
窗體類:
public function configure()
{
$this->setWidgets(array(
'vendor' => new sfWidgetFormInputText(array(), array('class' => 'form-text')),
'image' => new sfWidgetFormInputFile(array(), array('class' => 'form-text')),
'city' => new sfWidgetFormInputText(),
'email' => new sfWidgetFormInputText(array('default' => '[email protected]')),
'contacts' => new sfWidgetFormTextarea(),
'description' => new sfWidgetFormTextarea(),
));
$this->setValidators(array(
'vendor' => new sfValidatorString(array('required' => false)),
'image' => new sfValidatorFile(array(
'required' => false,
'path' => sfConfig::get('sf_upload_dir') . '/images',
'mime_types' => 'web_images')),
'city' => new sfValidatorString(array('required' => false)),
'email' => new sfValidatorString(array('required' => false)),
'contacts' => new sfValidatorString(array('required' => false)),
'description' => new sfValidatorString(array('required' => false)),
));
$this->widgetSchema->setNameFormat('pv[%s]');
}
行動:
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
return $this->renderText(var_dump($request->getParameter('pv'))); //this array include vars from form
//return $this->renderText(var_dump($request->getFiles('pv'))); //empty array
}
好吧,我明白我的問題,我是用JQ插件,並提交按鈕是jq_submit_to_remote()這是不是演戲正如我所想的那樣。 – bduisenov 2011-04-29 04:58:07