问题描述
大家帮帮我啊!我这里有个程序,需要接收post传过来的图片数据,并采用ASPJPEG压缩,现在的问题是:采用System.Drawing.Image可以将POST过来的图片接收,但是我不会将这个接收的数据传递给ASPJPEG,只能先存到服务器硬盘上,然后再用ASPJPEG打开后压缩,这样就多了个存储到服务器上的过程,现在大家帮帮我看看怎么直接用ASPJPEG接收这个图片文件啊!我试过了ASPJPEG网站上的方法(objJpeg.Open(Request["path"]),但是不管用,有错误,怎么解决呢?usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.IO;usingSystem.Collections.Generic;publicpartialclassupload:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){System.Drawing.Imageoriginal_image=null;try{//Getthedatastringfile_id=Request.QueryString["file_id"]asstring;HttpPostedFilejpeg_image_upload=Request.Files["Filedata"];//creataspjpegprojectASPJPEGLib.IASPJpegobjJpeg;objJpeg=newASPJPEGLib.ASPJpeg();//Retrievetheuploadedimageoriginal_image=System.Drawing.Image.FromStream(jpeg_image_upload.InputStream);//先保存到服务器上stringpicpath=Server.MapPath("images/1.jpg");original_image.Save(picpath,System.Drawing.Imaging.ImageFormat.Jpeg);//重新打开objJpeg.Open(picpath);//删除服务器上的较大的图片文件File.Delete(Server.MapPath("images/1.jpg"));//Resizingisoptional.Noneinthiscodesample.if(objJpeg.Width/objJpeg.Height>=1){objJpeg.Width=400;objJpeg.Height=objJpeg.OriginalHeight*objJpeg.Width/objJpeg.OriginalWidth;}else{objJpeg.Height=400;objJpeg.Width=objJpeg.OriginalWidth*objJpeg.Height/objJpeg.OriginalHeight;}objJpeg.Canvas.DrawBar(1,1,objJpeg.Width,objJpeg.Height);objJpeg.Save(Server.MapPath("images/1_new.jpg"));}catch{//Ifanykindoferroroccursreturna500InternalServererrorResponse.StatusCode=500;Response.Write("Anerroroccured");Response.End();}finally{//Cleanupif(original_image!=null)original_image.Dispose();}}}
大家看看帮帮我吧!
解决方案
解决方案二:
没有人知道吗,急死我了。这样做对吗?