时间:2021-05-28
之前有一篇写的如何同时传递form表单及upload组件文件,如果有多个upload文件该如何传递呢
上代码
html
<el-form ref="newform" :model="newform" :rules="rules"> <el-form-item prop="expName" label=""> <el-input v-model="newform.expName" placeholder="" style="width:75%"> </el-input> </el-form-item> <el-form-item prop="expSn" label=""> <el-input v-model="newform.expSn" placeholder="" style="width:75%"> </el-input> </el-form-item> <el-form-item label='' prop="groupName"> <el-select v-model="newform.groupName" placeholder="" style="width:75%" @change="newSelectGroup($event)"> <el-option v-for="item in groupOptions" :key="item.groupId" :label="item.groupName" :value="item.groupId"> </el-option> </el-select> </el-form-item> <el-form-item label="" prop="subGroupName"> <el-select v-model="newform.subGroupName" placeholder="" style="width:75%" @change="newSelectSubGroup($event)"> <el-option v-for="item in subGroupOptions" :key="item.subGroupId" :label="item.subGroupName" :value="item.subGroupId"> </el-option> </el-select> </el-form-item> <el-form-item label="" prop="expvmDifficulty"> <el-rate v-model="newform.expvmDifficulty" :max="5" style="line-height: 2;"></el-rate> </el-form-item> <el-form-item label="" prop="expvmInstruction"> <el-upload class="upload-demo" drag ref="uploadhtml" :action="upload_url" :auto-upload="false" :before-upload="newHtml" accept=".html, .htm"> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div slot="tip" class="el-upload__tip">实验信息上传,只能传(.html/.htm)文件</div> </el-upload> </el-form-item> <el-form-item label="" prop="expvmFiles"> <el-upload class="upload-demo" drag ref="uploadfile" :action="upload_url" :auto-upload="false" :before-upload="newFiles" multiple> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div slot="tip" class="el-upload__tip">实验信息附件上传,只能传(.file)文件</div> </el-upload> </el-form-item> <el-form-item label="" prop="expvmVideo"> <el-upload class="upload-demo" drag ref="uploadvideo" :action="upload_url" :auto-upload="false" :before-upload="newVideo" accept=".mp4"> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div slot="tip" class="el-upload__tip">实验视频上传,只能传(.mp4)文件</div> </el-upload> </el-form-item> <el-form-item style="text-align:center"> <el-button type="primary" @click="newSubmitForm()" class="yes-btn"> 确 定 </el-button> <el-button @click="resetForm('newform')"> 重 置 </el-button> </el-form-item> </el-form>js
methods
PHP代码,后台接收
public function newExp() { $param = $this->request->post(); // 获取页面表单传值 $files = $this->request->file(); // 接收到的文件 }注意
这里是接收多文件一定要是数组形式的file[]
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文介绍了vue项目中使用element-ui的Upload上传组件的示例,分享给大家,具体如下:确定其中importFileUrl是后台接口,upLoadDa
直接通过element-ui自带的上传组件结合js即可,代码如下:HTML:重新上传js:beforeAvatarUpload(file){varfileNam
element-ui上传一张图片后隐藏上传按钮el-upload里面绑定一个占位class::class="{hide:hideUpload}"data里面初始
element-ui组件的tree树形控件修改源码改为iview组件实现原理修改了element-ui源码,把源码里面的tree模块提取出来然后修改elemen
在vue2.0中引用element-ui组件库element-ui是由饿了么团队开发的一套基于Vue2.0的桌面端组件库。官网:http://element.e