发布时间:2026-07-02阅读(0)
use yii\web\UploadedFile;public function actionUpload(){ Yii::$app->response->format = Response::FORMAT_JSON; if(Yii::$app->request->isPost) { $image = UploadedFile::getInstanceByName(img); imageName =imageName=image->getBaseName(); ext =ext=image->getExtension(); $rootPath = assets/images/; path =path=rootPath.date(Y/m/d/); if (!file_exists($path)) { mkdir($path, 0755, true); } fullName =fullName=path.imageName.imageName.ext; if(image->saveAs(image−>saveAs(fullName)) { return [code=>1, message=>保存图片成功, data=>$fullName]; } else { return [code=>0, message=>保存图片失败, data=>$image->error]; } } else { return [code=>0, message=>不是POST]; }},现在小编就来说说关于Yii框架面试题?下面内容希望能帮助到你,我们来一起看看吧!

Yii框架面试题
use yii\web\UploadedFile;
public function actionUpload(){ Yii::$app->response->format = Response::FORMAT_JSON; if(Yii::$app->request->isPost) { $image = UploadedFile::getInstanceByName(img); imageName =imageName=image->getBaseName(); ext =ext=image->getExtension(); $rootPath = assets/images/; path =path=rootPath.date(Y/m/d/); if (!file_exists($path)) { mkdir($path, 0755, true); } fullName =fullName=path.imageName.imageName.ext; if(image->saveAs(image−>saveAs(fullName)) { return [code=>1, message=>保存图片成功, data=>$fullName]; } else { return [code=>0, message=>保存图片失败, data=>$image->error]; } } else { return [code=>0, message=>不是POST]; }}
Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图