0

I am trying to upload file using 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);
    }))

my wcf service code

[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;
}

My html content

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

When i click upload button. My service is not calling, not any response.

But other methods in my WCF service getting calling.

Any help

Gnana Akilan
  • 101
  • 1
  • 6

0 Answers0