中雪
中雪
  • 发布:2015-12-21 17:35
  • 更新:2015-12-21 17:35
  • 阅读:1401

请问大牛5 plus 中plus.webview.create()用这个接口上传照片到wcf rest指定的接口,后台要怎么写啊!

分类:HTML5+

请问大牛5 plus 中plus.uploader.createUpload()用这个接口上传照片到wcf rest指定的接口,后台要怎么写啊!
一直不能接收到传过来的值。
我已经能够用这种 方式获取到前面传过来的 stream但不知道怎么解密图片。
public string UploadImg(Stream stream)
{
// HttpRequest request = HttpContext.Current.Request;
//HttpPostedFileBase reqest
if (stream == null)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
return null;
}
StreamReader reader = new StreamReader(stream);
string res = reader.ReadToEnd();
string imgPath = string.Empty;
try
{
long incomingLength = WebOperationContext.Current.IncomingRequest.ContentLength;
WebHeaderCollection w= WebOperationContext.Current.IncomingRequest.Headers;
var s = w["zeng"];
var img = w["base64Img"];

            string diskPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img");  
            DirectoryInfo di = new DirectoryInfo(diskPath);  
            if (!di.Exists)  
            {  
                di.Create();  
            }  
            imgPath = string.Format("{0}\\{1}.{2}", di.FullName, Guid.NewGuid().ToString(), "jpg");  

            //byte[] arr = Convert.FromBase64String(img.Split(',')[1]);  
          //  MemoryStream ms = new MemoryStream(arr);  
            var  bmp = Bitmap.FromStream(stream);   
            bmp.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg);   
           // ms.Close();  

        }  
        catch  
        {  
            WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;  
        }  
        return imgPath;  
    }
2015-12-21 17:35 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复