vue 图片上传
<input class="file" name="file" type="file" accept="image/png,image/gif,image/jpeg" @change="certificate" @focus="hint=''"/>
certificate(e) { let file = e.target.files[0]; let param = new FormData(); //创建form对象 param.append('file', file, file.name); //通过append向form对象添加数据 let config = { headers: { 'Content-Type': 'multipart/form-data' } }; //添加请求头 this.axios.post('api/filesys/upload', param, config) .then(response => { this.images1 = null this.images1 = response.data.filepath; this.cards = " "; }).catch((error) => { this.cards = "出现错误了再次选择图片吧"; }); },