//选择文件夹handleFileUpload(event){ this.modeList = document.get
想要实现可以上传文件和文件夹这个操纵,
实现代码:
1.html:
<el-upload action="https://jsonplaceholder.typicode.com/posts/" :http-request="modeUpload"> <el-button size="small" type="primary">选择文件</el-button> </el-upload> <el-button size="small" type="primary" @click="chooseFiles">选择文件夹</el-button> <div v-show="false"> <input type="file" ref="file" webkitdirectory directory multiple="multiple" v-on:change="handleFileUpload($event)" /> </div>
2.data:
modeList: ‘‘,
3.methods:
//选择文件 modeUpload: function(item) { this.modeList = item.file; }, //触发文件夹选择 chooseFiles(e){ document.getElementById(‘file‘).click(); }, //选择文件夹 handleFileUpload(event){ this.modeList = document.getElementById("file").files; },
4.上传:
let formData = new FormData(); // 把文件信息添加进如东西 formData.append(‘file‘, this.modeList);
注意:
1.选择了文件夹后,qq空间相册密码破解方法 ,默认选择了该文件夹下的所有文件。
上传文件及文件夹
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/27371.html
- 上一篇: // 前端本地测试域名 ‘:8066‘
- 下一篇:他按键的速度非常快