必须是一些简单的解决办法,但作为初学者,我已经花了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