File Receive upload

Source: Internet
Author: User

    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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.