Chila JQuery Thumbnail _ Client File Download < 24 >

Source: Internet
Author: User

First, thumbnail image

--"first to find a picture, or to combine with the user's upload

--"Create a canvas unlike before is our canvas gives it a fixed size

--Create a brush

--》

Context. Response.ContentType ="Image/jpeg"; //get the path to the picture        stringFilePath = context. Server.MapPath ("image/1.jpg"); //Reading Pictures        using(Image img =Image.FromFile (FilePath)) {            //Create a canvas, fixed size (that is, the size of the thumbnail)            using(Bitmap map =NewBitmap ( $, -))            {                //Create a brush                using(Graphics g =graphics.fromimage (map)) {                    //draw the picture onto the canvas and note that the second parameter is the width and height of the canvas that is setg.drawimage (IMG,NewRectangle (0,0, map. Width, map. Height),NewRectangle (0,0, IMG. Width, IMG.                    Height), GraphicsUnit.Pixel); //Outputmap. Save (context.                Response.outputstream, System.Drawing.Imaging.ImageFormat.Jpeg); }            }        }

Second, the file download

Context. Response.ContentType ="text/html"; //Obtain the download file name for the client request        stringDownfilename=context. request.querystring["name"]; if(!string . IsNullOrEmpty (Downfilename)) {//determine if a client requests a downloaded file on the server//get the full path of the file first            stringFilePath =context.            Server.MapPath (Downfilename); if(File.exists (FilePath)) {//to file love your path transcoding to prevent garbled when output to the client                stringfile=context.                Server.URLEncode (FilePath); //want the user to pop up a save dialog boxcontext. Response.AddHeader ("content-disposition","attachment;filename=\ ""+ file +"\""); //if present, output the file to the client through the WriteFile (_) methodcontext.            Response.WriteFile (FilePath); }            Else{context. Response.Write ("file does not exist, make sure the path to the file is correct"); }        }

Chila JQuery Thumbnail _ Client File Download < 24 >

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.