jQueryAjax将jpg图像发布到.NETWebService。图像结果已损坏

jQueryAjax将jpg图像发布到.NETWebService。图像结果已损坏,jquery,.net,ajax,rest,cordova,Jquery,.net,Ajax,Rest,Cordova,我有一个phonegap jQuery应用程序,可以打开相机拍照 然后,我将这张图片发布到一个.NETWebService,我已经对它进行了编码 我不能使用phonegap文件传输,因为Bada操作系统不支持这种传输,这是一项要求 我已经成功地从phonegap文件系统API加载了该映像,并将其附加到.ajax type:post中,我甚至从.net端收到了该映像,但当.net将该映像保存到服务器时,映像结果已损坏 ->>这是一个正确的Base64编码文件,但有以下标题“data:image/j

我有一个phonegap jQuery应用程序,可以打开相机拍照

然后,我将这张图片发布到一个.NETWebService,我已经对它进行了编码

我不能使用phonegap文件传输,因为Bada操作系统不支持这种传输,这是一项要求

我已经成功地从phonegap文件系统API加载了该映像,并将其附加到.ajax type:post中,我甚至从.net端收到了该映像,但当.net将该映像保存到服务器时,映像结果已损坏

->>这是一个正确的Base64编码文件,但有以下标题“data:image/jpeg;Base64,/9j/4AAQ….=”

我如何摆脱这个标题?我应该从.net还是从ajax来修剪它

任何帮助都将不胜感激

这是我的代码:

//PHONEGAP CAMERA ACCESS (summed up)
navigator.camera.getPicture(onGetPictureSuccess, onGetPictureFail, { quality: 50, destinationType:Camera.DestinationType.FILE_URI });
window.resolveLocalFileSystemURI(imageURI, onResolveFileSystemURISuccess, onResolveFileSystemURIError);
fileEntry.file(gotFileSuccess, gotFileError);
new FileReader().readAsDataURL(file);


//UPLOAD FILE
function onDataReadSuccess(evt) {
        var image_data = evt.target.result;
        var filename = unique_id();
        var filext = "jpg";
                
         $.ajax({
                type : 'POST',
                url : SERVICE_BASE_URL+"/fotos/"+filename+"?ext="+filext,   
                cache: false, 
                timeout: 100000, 
                processData: false, 
                data: image_data, 
                contentType: 'image/jpeg',
                success : function(data) {
                       
                            console.log("Data Uploaded with success. Message: "+ data);
                            $.mobile.hidePageLoadingMsg();
                            $.mobile.changePage("ok.html");
                       }
                       });
            }
在我的.net Web服务上,这是被调用的方法:

public string FotoSave(string filename, string extension, Stream fileContent)
{
   string filePath = HttpContext.Current.Server.MapPath("~/foto_data/") + "\\" + filename;
   FileStream writeStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
   int Length = 256;
   Byte[] buffer = new Byte[Length];
   int bytesRead = readStream.Read(buffer, 0, Length);
   // write the required bytes
   while (bytesRead > 0)
   {
      writeStream.Write(buffer, 0, bytesRead);
      bytesRead = readStream.Read(buffer, 0, Length);
   }
   readStream.Close();
   writeStream.Close();
 }

好的,我让它工作了。问题是,当我们使用$.ajax()时,结果是一些必须作为文本放入html的内容,例如,您可以将其直接放入标记中

<textarea> background-image: data:data:image/jpeg;base64,/9j/4AAQ.....=</textarea>

传入的evt参数是什么?
 //Convert input stream into string
 StreamReader postReader = new StreamReader(inputStreamFromWebService);
 string base64String = postReader.ReadToEnd();
 if (base64String.StartsWith("data:"))
 {
            //remove unwanted ajax header
            int indexOfBase64String = base64String.IndexOf(",") + 1;
            int lenghtOfBase64String = base64String.Length - indexOfBase64String;
            base64String = base64String.Substring(indexOfBase64String, lenghtOfBase64String);
  }

  //Convert from base64 string to byte[]
  byte[] byteFromString;
  byteFromString = Convert.FromBase64String(base64String);
  MemoryStream stream = new MemoryStream(byteFromString);

  System.IO.FileStream outFile;
  outFile = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
  outFile.Write(byteFromString, 0, byteFromString.Length);
  outFile.Close();