0

以下是 Web Service 方法的外观:

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class FileUploadService
{
    [WebInvoke(UriTemplate = "UploadFile/{folder}/{fileName}", Method = "POST")]
    public void UploadFile(string folder, string fileName, Stream fileContents)
    {
        // Code removed for brevity. Basically we are reading the fileContents into FileStream and saving it on server.

    }
}

我能够编写一个小型 .NET 应用程序并使用此 Web 服务。我的问题是如何从 jQuery 中使用它?任何帮助深表感谢。提前致谢。

//深浅

4

1 回答 1

0

我不确定使用 Stream 并从 javascript 中使用它。您可以使用 HTML5 FileReader API 上传文件。- 示例 - http://www.dotnetthoughts.net/how-to-upload-multiple-files-with-html5-and-jquery/

于 2013-10-10T09:25:47.067 回答