c# - 发送文件上传到WCF

标签 c# javascript asp.net wcf

我有文件上传和一些输入文本,我想使用 WCF 将值更新到数据库。

到目前为止,我通过字符串数组发送所有输入值,但我不知道如何使用 WCF 将文件上传到服务器

html:

 <input id="file" type="file" >
   <textarea name="textarea" class="jqte"> </textarea>
...

JavaScript:

 $.ajax({
                url: "/WebServices/forum.svc/InsertMessage",
                type: "POST",
                data: JSON.stringify({ currentMessage: currentMessage }),
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function (data) {

                }
            });

WCF:

  [OperationContract]
        public void InsertMessage(List<string> currentMessage)
        {

            return;
        }

知道如何解决这个问题吗?

谢谢

巴罗兹

最佳答案

我最近尝试了同样的事情,但失败了。

这种情况最好使用js。 http://www.enfew.com/12-excellent-ajax-upload-plugins/

如果您使用的是现代浏览器,其中许多会使用 ajax,或者如果您使用的是旧浏览器,则返回到 iFrame。因此浏览器兼容性也不是问题。

我自己用过https://code.google.com/p/upload-at-click/ .它使用起来非常简单,并且可以满足您的需要。

关于c# - 发送文件上传到WCF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18081674/

相关文章:

c# - 如何在 asp .net 中避免 treeview 的父 css 类样式?

javascript - 未检查的最后一个错误值 : Error: No matching window - I get this error when trying to execute script with command in Firefox WebExtension

c# - 业务对象数据访问层的最佳 "pattern"

c# - 将元素插入列表时参数超出范围异常

c# - 我们如何在 ASP.NET 身份中实现权限?

c# - WPF:使用 GridSplitter 隐藏网格行

javascript - 无法使用 ngShow 为自定义指令设置动画

javascript - Array.prototype.isPrototypeOf 和 A​​rray.isPrototypeOf 有什么区别?

asp.net - Webforms session 值现在应该存储在 MVC 不记名 token 中吗?

c# - ASP.NET Gridview 列大小调整