1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| function clickInput() { this.$refs['file'].click() }
function uploadFile(e) { let files = e.target.files
let formData = new FormData() formData.append('apk', files[0]) formData.append('other', '其他属性值') requestFileDate(formData).then(res => { console.log(res.data) }) }
function changeImg(e) { var imageFile = e.target.files[0] if (!e || !window.FileReader) return let reader = new FileReader() reader.readAsDataURL(imageFile) let _this = this reader.onloadend = function() { _this.previewSrc = this.result } this.reqFormData = new FormData() this.reqFormData.append('base_image', imageFile) e.srcElement.value = '' }
export function requestFileDate(data) { return request({ url: '/upload', method: 'post', data: data, headers: { 'Content-Type': 'multipart/form-data' } }) }
|