Here is what I am trying to do (unsuccessfully, I might add) and would appreciate any direction you can give me
From my HTML5 site, I want to upload a file to a cross domain WCF service that is hosted in IIS 7.5.
In addition to uploading the files, I need to send additional parameters to the upload fucntion on the server
Is this possible to do?
Here is what my operationContract looks like:
[OperationContract]
[WebInvoke( Method = "POST",
UriTemplate = "/uploadmodeldata/?id={Id}&customerdatatype={customerdatatype}&data={data}")]
void UploadModelData(string Id, string customerdataType, byte[] data);
Here is what my jquery ajax request
function FileVisits() {
var uid = checkCookie1();
userid = uid.toString().replace(/"/g, '');
var fileData = JSON.stringify({
Id:userid ,customerdatatype:scanupload,
data: $('#fileBinary').val()
});
alert(fileData);
"use strict";
var wcfServiceUrl = "http:
$.ajax({
cache: false,
url: wcfServiceUrl + "uploadmodeldata/",
data: fileData,
type: "POST",
processData: false,
contentType: "application/json",
timeout: 10000,
dataType: "json",
headers: {
'User-agent': 'Mozilla/5.0 (compatible) Greasemonkey',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
beforeSend: function (xhr) {
$.mobile.showPageLoadingMsg();
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
},
complete: function () {
$.mobile.hidePageLoadingMsg();
},
success: function (data) {
var result = data;
},
error: function (data) {
alert("Error");
}
});
}
if file size is less then 100 kb this error occurred
> Method not allowed
but if file is greater then 100 kb this error occurred
> 413 Request entity to large
How can I upload a file from jquery ajax to cross domain wcf.
Thanks