<template>
 <view>
  <view ref="input" class="input">
   附件上传
  </view>
  
  
 </view>
</template>

<script>
 export default {
  data() {
   return {
    
   }
  },
  // uni-app input不支持type=“file”类型所以需要js创建
  mounted() {
   // 创建附件上传
   var _self = this;
   var input = document.createElement('input');//创建元素
   input.type = 'file'//添加file类型
   input.onchange = (event) => {
    _self.upFile(input, event)
   }
   this.$refs.input.$el.appendChild(input)
  },
  //上传
  methods: {
   upFile(input, event) {
    var _self = this;
    uni.uploadFile({
     url: 'http://124.71.174.104:8081/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
     files: [
      {
       file: input.files[0],
       uri: event.srcElement.value
      }
     ],
     success: (uploadFileRes) => {
      console.log(uploadFileRes)
     },
     fail: (err) => {
      console.log(err)
     }
    });
   },
  }
  
 }
</script>

<style>

</style>