【问题标题】:using jQuery how to consume REST based WCF web service to upload file使用 jQuery 如何使用基于 REST 的 WCF Web 服务来上传文件
【发布时间】:2013-10-10 09:20:37
【问题描述】:

下面是 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 中使用它?任何帮助深表感谢。提前致谢。

//桑迪普

【问题讨论】:

    标签: jquery .net wcf rest


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-17
      • 1970-01-01
      相关资源
      最近更新 更多