How to upload a file to a WCF Service?

前端 未结 4 1135
半阙折子戏
半阙折子戏 2020-12-09 09:32

I\'ve build a WCF Service to accept a file and write it to disk. The front-end consists of a page with SWFUpload which is handling the upload on the client side. Apparently,

相关标签:
4条回答
  • 2020-12-09 10:12

    It might be that your WCF service targets .NET Framework 3.5 and your IIS is running on .NET Framework 4.0. In this case (framework mismatch) you need to modify your service.

    0 讨论(0)
  • 2020-12-09 10:20

    I believe you are going to have to tranfer the file as a byte array to WCF. You will need to handle the post from SWFUpload and convert to a byte array before sending to your service.

    0 讨论(0)
  • 2020-12-09 10:25

    What you want to use is probably MTOM, if you want it to be standard. Using this, you can have MIME multiparts messages.

    You then have to read the file as a stream and stuff it into one of the parameters of the request.

    0 讨论(0)
  • 2020-12-09 10:28

    @jdiaz,

    @JasonS is right, to upload file you need to transfer it as a byte stream. You need to use WCF streaming. For example on how to upload file via WCF see an article from http://kjellsj.blogspot.com

    0 讨论(0)
提交回复
热议问题