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 >