yii2.0里自己写的源码上传图片

时间:2022-04-20 05:57:00

在做项目过程中,用了源码表单上传,

<form action="?r=pre/create" method="post" enctype="multipart/form-data">

<input type="file" name="company_logo" class="valid">

</form>

但是上传不成功,而是缺少该配置,vendor\yiisoft\yii2\web\UploadFile.php

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA7EAAACxCAIAAACdqa2TAAAgAElEQVR4nO3dz2sc15738flbmljVltSKfpre2Bfb8DxGMiJtnIUd4Z089oWL5UDrWYabjTcXJtKqCTzZCML4WQwYMdzbBLyZSdaeno2aLAJ3O7kYvJLx5lnUr/P7nK7u6qpWveFFiLt+nVP966Nvnzr1T1G7FbVb/+t/347/Z86qOq7X3cdP+i/37hbc8En/5ZODO9X34gq3GQBQqc4Xh8l3R+Jxt+omAVP5p8pbAAAAAFQrycTUiQEAANBY1IkBAADQdNSJAQAA0HTUiQEAANB0C1Mnvvv4ybP9jm+1zheHT/qHd3aqPq0AAABYILWvE9/Zi6Pwzv7D+H/uPrZPGbZz5xkTigEAAGBCda8T7+w/7L980j+8c3f/4bP9bjwboq1gfPcxRWIAAABMrPZ14nYrEm4q4ZwSvHtgj8sAAACATd3rxLGQTLyz/7DYnecAAADQcHWvEwePneh8cciNJQEAAFBE7evEgdfY3dnrv3z4xU71JxQAAAALp+514oxzLjamYAMAAEBxta8Th2AKNgAAAExhYerEDncfP+HqOgAAABR2BerETMEGAACAqSx8nXhn/yFX1wEAAGAai14nZgo2AAAATGvB68RMwQYAAICpLXSdmCnYAAAAMAMLXicGAAAAprbQdWIAAABgBqgTA6iXT93ulVf5SQYAKCquEwNooP/5n787ll75yHjlOwgAi4g6MYB5IxNX3gYAgII6MYB5IxNX3gYAgII6MYB5M2bi3mB0OTyKDJFxbzD+cDHYq7zZs+LLxFetv2XoDUacIgCztdh14v7S1x+XHvWtK9waLn39MTWMHOscDsxLF1H5Pdo9ORi/f5p68LzyLr94UJeWIIieiXuD0eXlh+FxKzJExqNhuqgcR8PL8Ax6NLz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AADQdNSJAQAA0HTUiQEAANB01IkBAADQdNSJAQAA0HTUiQEAANB01IkBAADQdNSJAQAA0HTUiQEAANB01IkBAADQdNSJAQAA0HTUiQEAANB0NawTd744fNI/vLMjP3738ZNn+x3bVu6lAAAAgEP96sQ7d569fHJwJ/3nnb047O7sP4z/5+7j4KUAAABAgNrVie8+lorEO/sP+y+f9A/v3N1/+Gy/+8Xhk/7LvCTsXgoAAACEqFuduHtgCrV3Hz/pv3zSf/mk/7irb+VeCgAAALjVq068s/+w/3LvrvY4mRgAAADlqVWduPPFoZprGTsBAACAstWpTnxnr//y4Rc76oNcYwcAAIBS1adObJ6CLcNcbAAAAChJberEyhRsAAAAwLzUpU589/ET49V1AAAAQNlqUic2T8EGAAAAzEEt6sQ7+w8NV9cBAAAAc1GHOrFhCjYAAABgbmpQJzZOwQYAAADMS+V1Ys8UbAAAAEDZalAnBgAAACpVeZ0YAAAAqNj/B1jJSk6tITSAAAAAAElFTkSuQmCC" alt="" />

再次上传发现能上传了。具体代码如下

写了单独的图片上传model:(UploadForm.php)

 <?php
namespace app\models;
use yii\base\Model;
use yii\web\UploadedFile;
/**
* UploadForm is the model behind the upload form.
*/
class UploadForm extends Model
{
/**
* @var UploadedFile file attribute
*/
public $company_logo;
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[['company_logo'], 'file'],
];
}
}

在控制器写了:(PreController.php)

举例其中的添加方法

   //编辑简历方法
public function actionCreate()
{
$model = new YiiCompanyInfo();
$upload_model = new UploadForm();
if (Yii::$app->request->isPost) {
//获取cookie登录信息
$cookies = Yii::$app->request->cookies;
$user=unserialize($cookies->getValue('user'));
$post=\Yii::$app->request->post();
//上传过程
$upload_model->company_logo = \yii\web\UploadedFile::getInstance('company_logo'); if ($upload_model->company_logo && $upload_model->validate()) {
$filename='logoimage/' . $upload_model->company_logo->baseName . '.' . $upload_model->company_logo->extension; $upload_model->company_logo->saveAs($filename);
$post['company_logo']='http://localhost/yii3/JoinUs/project/frontend/web/'.$filename;
}
//print_r($post); die;
$a= yii::$app->db->createCommand()->insert('yii_company_info', [
'company_id' => $user['company_id'],
'company_name' => $post['company_name'],
'company_desc' => $post['company_desc'],
'company_address' => $post['company_address'],
'company_phone' => $post['company_phone'],
'company_index' => $post['company_index'],
'company_type' => $post['company_type'],
'company_logo' => $post['company_logo'],
'company_scale' => $post['company_scale'],
'company_radio' => $post['company_radio'],
])->execute();
if ($a) {
return $this->render('success.php');
} }else{
return $this->renderPartial('index01.php');
}
}

model层就不写了,记得在web目录下建好存储图片目录。


注:本文由王智磊(王大宝儿)整理编写,也参考借鉴了很多大神的笔记,分享代码,分享成功,欢迎各位交流和转载,转载请注明出处(博客园:王大宝儿)http://www.cnblogs.com/wangzhilei/