I am trying to upload a file from html 5 using wcf rest and jquery.its working fine in local.but not in server.kindly help me to solve this issue.
my js code is
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!');
}
});
}
my service is
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/UploadFileNew", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
I got the following error
XMLHttpRequest cannot load... The request was redirected to....
which is disallowed for cross-origin requests that require preflight.
kindly help me