本文整理汇总了PHP中FileUpload::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload::getErrors方法的具体用法?PHP FileUpload::getErrors怎么用?PHP FileUpload::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload::getErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadBiz(trim($id));
$model->setScenario('sell');
$this->performAjaxValidation($model);
if (!empty($_POST)) {
$model->attributes = $_POST['ARBiz'];
// dump($_FILES);
// 控制器中使用实例如下:
$upload = new FileUpload(array($model, 'license_photo'), 'upload/groupon');
//model处理文件上传 $upload = new FileUpload(array($model,'pic'),'upload/goods');
if (!$upload->isNull()) {
if ($filename = $upload->save()) {
$model->license_photo = $filename;
// dump($filename);
} else {
print_r($upload->getErrors());
throw new CHttpException('300', '文件上传失败');
}
}
// dump($model->attributes);
if ($model->save()) {
// $return_url = $_POST['return_url'];
$this->redirect(array('index'));
}
}
$this->render('update', array('model' => $model));
}
示例2: actionUpdate
public function actionUpdate($id)
{
$model = ARGroupon::model()->findByPk($id);
if ($model == null) {
$this->go('该商品不存在', Yii::app()->request->urlReferrer);
}
$model->setScenario('sell');
$this->performAjaxValidation($model);
if (!empty($_POST['ARGroupon'])) {
// dump($_FILES);
// dump($_POST);exit;
$model->attributes = $_POST['ARGroupon'];
if ($model->validate()) {
$fileUpload = new FileUpload(array($model, 'image'), 'upload/groupon');
if (!$fileUpload->isNull()) {
$filename = $fileUpload->save();
if ($filename) {
$model->image = $filename;
} else {
dump($fileUpload->getErrors());
throw new CHttpException(300, '图片上传出错');
}
}
$model->begin_time = strtotime($model->begin_time);
$model->end_time = strtotime($model->end_time);
$model->expire_time = strtotime($model->expire_time);
if ($model->save()) {
Yii::app()->user->setFlash('success', '商品修改成功');
// $url = $_POST['return_url'];
// $this->go('商品修改成功', $url, 'success');
}
}
}
$this->render('update', array('model' => $model));
}