public function actionUpload_iframe($type) { $this->enableCsrfValidation = false; if (Yii::$app->request->isPost) { $err = ''; if ($_FILES['photo']['size'] >= '4096000') { $err = '请不要上传超过4M的文件!'; } if (!in_array($_FILES['photo']['type'], array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'))) { $err = '请选择后缀名为jpg,png,gif的图片上传!'; } if ($err) { yii::$app->session->setFlash('upload_err', $err); return $this->renderPartial('upload_iframe'); } else { $file_name = md5(rand(1, 10000) . time()); Info::photo_resize($_FILES['photo']['name'], $_FILES['photo']['tmp_name'], 200, 200, Yii::getAlias("@webroot") . '/info_upload/temp/' . $file_name . '.jpg'); Info::photo_resize($_FILES['photo']['name'], $_FILES['photo']['tmp_name'], 160, 100, Yii::getAlias("@webroot") . '/info_upload/temp/' . $file_name . '_min.jpg'); return $this->renderPartial('upload_iframe', ['type' => $type, 'file_name' => $file_name]); } } else { return $this->renderPartial('upload_iframe'); } }