您好,欢迎访问一九零五行业门户网

yii框架如何实现文件上传

1、首先yii框架下载uploadfile类
2、html代码
<input type="file" class="file" style="display: none" name="business_license" />
(推荐教程:yii框架)
3、js代码
var business_license = $('.file').get(0).files[0];var data = new formdata();data.append('business_license',business_license);$.ajax({ url:url, data:data, type:'post', datatype:'json', processdata: false, contenttype: false, success:function(response){ }, error:function(response){ // console.log(response); }
4、php接收
$model = new model();//实例化数据库模型$model->business_license = uploadedfile::getinstance($model, 'business_license');$model->business_license->saveas($model->business_license->basename . '.' . $model->business_license->extension);
最后生成的文件地址为saveas下的路径,可自由修改。
更多编程相关内容,请关注编程入门栏目!
以上就是yii框架如何实现文件上传的详细内容。
其它类似信息

推荐信息