日期:2014-05-17 浏览次数:20457 次
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgModel.SourceUrl); request.Referer = Request.UrlReferrer.ToString(); request.UserAgent = Request.UserAgent; WebResponse response = request.GetResponse(); Stream imgStream = response.GetResponseStream(); if (imgStream != null) { Image img = Image.FromStream(imgStream, true, true); string extension = Common.GetImageFormat(img.RawFormat); //Bitmap bitmap = new Bitmap(img);//这里用bitmap方式保存也不行 //bitmap.Save(Request.MapPath("/Images/" + Guid.NewGuid().ToString()) + extension, img.RawFormat); img.Save(Request.MapPath("/Images/" + Guid.NewGuid().ToString()) + extension, img.RawFormat); WriteAsCrossDomain(Request["jsoncallback"], string.Format("'宽:{0},高:{1}'", img.Width, img.Height)); img.Dispose(); //bitmap.Dispose(); }