0
我想从html 5上传文件使用wcf休息和jquery.its工作正常在本地但不是在server.kindly帮我解决这个问题。jquery多个文件上传本地工作,但不是在Windows服务器
我的js代码是
function UploadFile() {
var ajaxdata = new FormData();
ajaxdata.append('action', 'col-xs-12 mid_forma');
$.each($("input[type=file]"), function (i, obj) {
$.each(obj.files, function (j, file) {
ajaxdata.append('photo[' + i + ']', file);
})
});
$.ajax({
url: HostingInvestmentURL + 'UploadFileNew/',
type: 'POST',
data: ajaxdata,
enctype: 'multipart/form-data',
cache: false,
dataType: 'json',
processData: false,
contentType: false,
success: function (data) {
//alert('Added Successfully');
},
error: function (data) {
alert('Some error Occurred!');
}
});
}
我的服务就是
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/UploadFileNew", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
我有以下错误
的XMLHttpRequest无法加载...请求被重定向到...
这是不允许需要预检的跨源请求。
好心帮我
拉杰感谢乌拉圭回合reply.but我在Global.asax.cs中添加这些东西文件 – Raja
保护无效的Application_BeginRequest(对象发件人,EventArgs的) HttpContext.Current.Response.AddHeader(“Access-Control-Allow-Origin”,“*”); (HttpContext.Current.Request.HttpMethod ==“OPTIONS”) HttpContext.Current.Response.AddHeader(“Access-Control-Allow-Methods”,“GET,POST”); HttpContext.Current.Response.AddHeader(“Access-Control-Allow-Headers”,“Content-Type,Accept”); HttpContext.Current.Response.AddHeader(“Access-Control-Max-Age”,“1728000”); HttpContext.Current.Response.End(); – Raja