0

我正在尝试使用 Esri request javascript api 上传文件。

esriRequest({
      url: "http://localhost:20659/service/Service.svc/Upload/",
      form : this.datafile,
      handleAs: "json",
      callbackParamName: "callback"
    },{usePost: true, useProxy:true}).then(lang.hitch(this,function(response){

    }), lang.hitch(this,function(error){
      console.log(error);
    }))

我的 wcf 服务代码

[OperationContract]
[WebInvoke(Method = "POST",
           UriTemplate = "Upload/",
           BodyStyle = WebMessageBodyStyle.Bare)]
UploadedFile Upload(System.IO.Stream Uploading);

public UploadedFile Upload(Stream Uploading)
{
    UploadedFile upload = new UploadedFile
    {
        FilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())
    };

    int length = 0;
    using (FileStream writer = new FileStream(upload.FilePath, FileMode.Create))
    {
        int readCount;
        var buffer = new byte[8192];
        while ((readCount = Uploading.Read(buffer, 0, buffer.Length)) != 0)
        {
            writer.Write(buffer, 0, readCount);
            length += readCount;
        }
    }

    upload.FileLength = length.ToString();

    return upload;
}

我的html内容

<form method="post" data-dojo-attach-point="datafile" enctype="multipart/form-data">
        <input type="file" name="Upload" id="uploadfile"  >
    </form>

当我点击上传按钮时。我的服务没有调用,没有任何响应。

但是我的 WCF 服务中的其他方法正在调用。

任何帮助

4

0 回答 0