Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用文件传输上载图像ionic 3在iOS上不工作_Asp.net_Ionic Framework_Ionic3 - Fatal编程技术网

Asp.net 使用文件传输上载图像ionic 3在iOS上不工作

Asp.net 使用文件传输上载图像ionic 3在iOS上不工作,asp.net,ionic-framework,ionic3,Asp.net,Ionic Framework,Ionic3,在爱奥尼亚3中使用文件传输上传图像在android上运行良好, 但在模拟器中尝试时,请告诉我iOS上的错误。。 *这就是错误: 我的爱奥尼亚密码: chooseImageFromGallery() { this.type="0" const options: CameraOptions = { quality: 60, destinationType: this.camera.DestinationType.FILE_URI, encodingType: th

在爱奥尼亚3中使用文件传输上传图像在android上运行良好, 但在模拟器中尝试时,请告诉我iOS上的错误。。 *这就是错误:

我的爱奥尼亚密码:

chooseImageFromGallery()
{
  this.type="0"

  const options: CameraOptions = {
    quality: 60,
    destinationType: this.camera.DestinationType.FILE_URI,
    encodingType: this.camera.EncodingType.JPEG,
    mediaType: this.camera.MediaType.PICTURE,
    saveToPhotoAlbum:true,
    sourceType:0
  }
  this.camera.getPicture(options)
  .then((imageData) => {
    if (this.platform.is('ios'))
    {
      this.base64Image  = imageData;
    }
    else
    {
      this.base64Image  = imageData;
    }

  this.uploadimage(); // this function to upload img to server

  },
  (err) => {

  }).then((path)=>{

  })

}

uploadimage(){

  this.photoSrc="";

this.translate.get("uploading Image...").subscribe(
  value => {
this.sucesss=false
const fileTransfer: FileTransferObject = this.transfer.create();
let options: FileUploadOptions = {
fileKey: "file",
fileName:'test',
chunkedMode:false,
mimeType:"image/jpeg",
headers:{
Connection:"close"
},
httpMethod: "POST",
  }

  //------------ android ------------//
  this.base64Image =this.base64Image
  //------------ ios ------------//
  //this.base64Image =this.base64Image.substring(28)

  fileTransfer.upload(this.base64Image,encodeURI('mydomain/api/Product/upload'), options)
.then((data:any) => {

    alert("upload success ")


}, (err) => {

  this.translate.get( "error in upload Data").subscribe(
    value => {
      this.service.presentToast(value,2000)
    }
  )
})
  })
}
使用asp.net api2。。我的服务器代码:

 [HttpPost]
    [Route("upload")]
    [AllowAnonymous]
    public HttpResponseMessage uploadImage()
    {
        var request = HttpContext.Current.Request;
        if (Request.Content.IsMimeMultipartContent())
        {
            foreach (string file in request.Files)
            {
                var postedFile = request.Files[file];
                if (postedFile != null && postedFile.ContentLength > 0)
                {
                    string root = HttpContext.Current.Server.MapPath("~/ServerImg");
                    root = root + "/" + postedFile.FileName;
                    postedFile.SaveAs(root);
                    //Save post to DB
                    return Request.CreateResponse(HttpStatusCode.Found, new
                    {
                        error = false,
                        status = "created",
                        path = root
                    });

                }
                else
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound, new
                    {
                        error = true


                    });
                }
                // var title = request.Params["title"];


            }

            //  }


            return null;
        }
        else
        {
            return Request.CreateResponse(HttpStatusCode.Forbidden, new
            {
                error = true


            }); 
        }
    }
我花了4天多的时间。。但对我来说什么都不管用。。 这段代码在Android上运行良好,但在iOS上不起作用。我不知道出了什么问题,我尝试了真正的iPhone和Xcode模拟器,但没有成功 总是上传错误{“代码”:3…“http_状态”:500


有人能帮我吗…

你找到解决办法了吗?你找到解决办法了吗?