3

使用 phonegap FileTransfer 上传和 webservice asmx 时出现错误

这是phonegap的代码

    function uploadNow(){           
       //alert(imgURI);
       var options = new FileUploadOptions();

       options.fileKey = "file";
       //options.fileName = imgURI.substr(imgURI.lastIndexOf('/') + 1);
       options.fileName = "face-275.jpg";
       options.mimeType = "image/jpeg";
       //alert(options.fileName);

       var params = new Object();
       params.value1 = "test";
       params.value2 = "param";
       options.params = params;

       var ft = new FileTransfer();
       ft.upload("file:///mnt/sdcard/Merabu Survey/Picture/face-275.jpg",
          "http://192.168.0.231/mservice/MainService.asmx/UploadService", 
          win, fail,  options);

这是我的 asmx 代码

[WebMethod]
        public string UploadService()
        {
            //string rootPathRemote = ConfigurationManager.AppSettings["UploadedFilesPath"].TrimEnd('/', '\\') + "/";
            //string rootPhysicalPathRemote = rootPathRemote + "\\";
            int fileCount = 0;

            fileCount = HttpContext.Current.Request.Files.Count;
            for (int i = 0; i < fileCount; i++)
            {
                HttpPostedFile file = HttpContext.Current.Request.Files[i];
                string fileName = HttpContext.Current.Request.Files[i].FileName;
                if (!fileName.EndsWith(".jpg"))
                {
                    fileName += ".jpg";
                }
                string sourceFilePath = Path.Combine("F:\\Live Website\\upload", fileName);
                file.SaveAs(sourceFilePath);
            }
            return "test";
        }

我从我的 adb 日志聊天中收到 http 状态 500 和错误代码 1 的错误。我已经将我的网络服务域添加到白名单。有谁知道如何解决这个问题?

4

0 回答 0