uploadFile上传图片到服务器,后台一直没有接收到参数?
发布于 5 年前 作者 myin 12449 次浏览 来自 问答

wx.chooseImage({

     success (res) {

        const tempFilePaths = res.tempFilePaths

        wx.uploadFile({

          url: 'https://******/uploadPic.ashx', //仅为示例,非真实的接口地址

          filePath: tempFilePaths[0],

          name: 'uploadfile',

          formData: {

            'user': 'test'

          },

          success (res){

            const data = res.data

            console.log(data)

            //do something

          }

        })

      }

    })

后端ashx

HttpPostedFile file = context.Request.Files[“uploadfile”];//接收

打印一直是null,无法接收到前端上传的文件路径?????????????????

1 回复

你先把 `context.Request.Files` 打印出来看一下集合里都有啥吧。

手头现在没小程序,印象里文件对应的 Key 是固定值 `file`、而不是你参数里的 `name`,那个 `name` 是指 filename。

回到顶部