protected voidPage_Load (Objectsender, EventArgs e) {Httppostedfile Jpeg_image_upload= request.files["Filedata"]; stringImageId =DateTime.Now.Ticks.ToString (); stringFileName =Path.getfilename (jpeg_image_upload. FileName); stringFileExtension =path.getextension (fileName); stringUploadname = ImageId +fileextension; if(Jpeg_image_upload. ContentLength >0) { stringIMAGEURL = Server.MapPath ("/uploadpic/product/"+ DateTime.Now.ToString ("yyyymm") +"/"+uploadname); if(!directory.exists (Path.getdirectoryname (IMAGEURL))) {Directory.CreateDirectory (Path.getdirectoryname (IMAGEURL)); } jpeg_image_upload. SaveAs (IMAGEURL); //Save large image and Watermark stringBigimg = Server.MapPath ("/uploadpic/product/"+ DateTime.Now.ToString ("yyyymm") +"/ C"+uploadname); if(!directory.exists (Path.getdirectoryname (bigimg))) {Directory.CreateDirectory (Path.getdirectoryname (bigimg)); } ncurrtimg.greateminiimage (ImageUrl, bigimg, -, -,"COM");//generate thumbnail images//Currtimg.addwatermark (tempimg, bigimg, "I");//Watermark//Save in picture stringMidimg = Server.MapPath ("/uploadpic/product/"+ DateTime.Now.ToString ("yyyymm") +"/ M"+uploadname); if(!directory.exists (Path.getdirectoryname (midimg))) {Directory.CreateDirectory (Path.getdirectoryname (midimg)); } ncurrtimg.greateminiimage (ImageUrl, midimg, $, $,"COM");//generate thumbnail images//Save small picture stringSmallimg = Server.MapPath ("/uploadpic/product/"+ DateTime.Now.ToString ("yyyymm") +"/ S"+uploadname); if(!directory.exists (Path.getdirectoryname (smallimg))) {Directory.CreateDirectory (Path.getdirectoryname (smallimg)); } ncurrtimg.greateminiimage (ImageUrl, smallimg, -, -,"COM");//generate thumbnail imagesResponse.statuscode= $; stringReturnstr = Jpeg_image_upload. Contentlength.tostring ();//0 SizeReturnstr = Returnstr +"|"+"/uploadpic/product/"+ DateTime.Now.ToString ("yyyymm") +"/ M"+ Uploadname;//1 URLReturnstr = Returnstr +"|"+ FileName;//2 titleReturnstr = Returnstr +"|"+ imageId;//3 IDReturnstr = Returnstr +"|"+"Wokaokao";//4 NameResponse.Write (RETURNSTR); Response.End (); } }
Public voidSavepic (intBrandid) {httpfilecollection fileList=HttpContext.Current.Request.Files; for(inti =0; i < Filelist.count; i++) {Httppostedfile file=Filelist[i]; stringFileName =System.IO.Path.GetFileName (file. FileName); stringFileExtension =System.IO.Path.GetExtension (fileName); stringUploadname = Brandid +fileextension; stringYearmonth = DateTime.Now.ToString ("yyyymm"); if(file. ContentLength >0) { stringImgpath ="/uploadpic/brandlogo/"+ Yearmonth +"/ C"+Uploadname; stringSmallimg =""; stringMidimg =""; Jtzk_brandmodel Entity=Brandbll.getentitymodel (Brandid); Entity. Brandlogo=Imgpath; Brandbll.update (entity); Imgpath="/uploadpic/brandlogo/"+ Yearmonth +"/ C"+Uploadname; Imgpath=Server.MapPath (Imgpath); File. SaveAs (Imgpath); Smallimg= Server.MapPath ("/uploadpic/brandlogo/"+ Yearmonth +"/ S"+uploadname); Ncurrtimg.greateminiimage (Imgpath, smallimg, -, -,"Cut"); Midimg= Server.MapPath ("/uploadpic/brandlogo/"+ Yearmonth +"/ M"+uploadname); Ncurrtimg.greateminiimage (Imgpath, midimg, -, -,"Cut"); } } }
Public voidsavepic (Jtzk_companymodel entity) {httpfilecollection fileList=HttpContext.Current.Request.Files; for(inti =0; i < Filelist.count; i++) {Httppostedfile file=Filelist[i]; stringFileName =System.IO.Path.GetFileName (file. FileName); stringFileExtension =System.IO.Path.GetExtension (fileName); stringUploadname = entity. Id +fileextension; stringYearmonth = DateTime.Now.ToString ("yyyymm"); if(file. ContentLength >0) { stringImgpath ="/uploadpic/companylogo/"+ Yearmonth +"/ C"+Uploadname; stringSmallimg =""; stringMidimg =""; Entity.companylogo=Imgpath; JTZK_COMPANYBLL BLL=NewJTZK_COMPANYBLL (); Bll. Update (entity); Imgpath=Server.MapPath (Imgpath); File. SaveAs (Imgpath); Smallimg= Server.MapPath ("/uploadpic/companylogo/"+ Yearmonth +"/ S"+uploadname); Ncurrtimg.greateminiimage (Imgpath, smallimg, -, +,"Cut"); Midimg= Server.MapPath ("/uploadpic/companylogo/"+ Yearmonth +"/ M"+uploadname); Ncurrtimg.greateminiimage (Imgpath, midimg, -, the,"Cut"); } } }
Public voidsavepic (Jtzk_regusermodel entity) {httpfilecollection fileList=HttpContext.Current.Request.Files; for(inti =0; i < Filelist.count; i++) {Httppostedfile file=Filelist[i]; stringFileName =System.IO.Path.GetFileName (file. FileName); stringFileExtension =System.IO.Path.GetExtension (fileName); stringUploadname = entity. Id +fileextension; stringYearmonth = DateTime.Now.ToString ("yyyymm"); if(file. ContentLength >0) { stringImgpath ="/uploadpic/userface/"+ Yearmonth +"/ C"+Uploadname; stringSmallimg =""; stringMidimg =""; Entity. Userface=Imgpath; JTZK_REGUSERBLL BLL=NewJTZK_REGUSERBLL (); Bll. Update (entity); Imgpath=Server.MapPath (Imgpath); File. SaveAs (Imgpath); Smallimg= Server.MapPath ("/uploadpic/userface/"+ Yearmonth +"/ S"+uploadname); Ncurrtimg.greateminiimage (Imgpath, smallimg, -, -,"W"); Midimg= Server.MapPath ("/uploadpic/userface/"+ Yearmonth +"/ M"+uploadname); Ncurrtimg.greateminiimage (Imgpath, midimg, -, -,"Cut"); } } }
File receive upload