0
if (isset($_POST['Software'])) {
            $_POST['Software']['sw_icon'] = $model->sw_icon;
            $model->attributes = $_POST['Software'];
            $uploadedFile = CUploadedFile::getInstance($model, 'sw_icon');
            $model->attributes = $_POST['Software'];
            $model->updated_date = date("Y-m-d H:i"); 
            if ($model->save()) {
                if (!empty($uploadedFile)) {  // check if uploaded file is set or not
                    $uploadedFile->saveAs(Yii::app()->basePath . '/../images/software_icons/' . $model->sw_icon);
                }
                Yii::app()->user->setFlash('success', 'Software updated successfully.');
                $this->redirect(array('index'));
            }
        }

当我使用上面的代码时,我收到以下错误

...函数move_uploaded_file():的第二个参数copy()不能是目录。

4

2 回答 2

0

您可以将文件移动到另一个文件名。您不能将文件移动到文件夹中。尝试Yii::app()->basePath . '/../images/software_icons/' . $model->sw_icon对此进行替换:Yii::app()->basePath . '/../images/software_icons/newfile'

于 2013-06-18T06:20:59.230 回答
0

你能告诉我结果吗Yii::app()->basePath . '/../images/software_icons/' . $model->sw_icon,好像是一个目录

于 2013-06-18T05:59:45.837 回答