About file download, many are used href= ' file address ', this is very insecure, so need to use to file stream, the following code is used to download a picture.
Response.bufferoutput =false; Response.Clear (); Response.ContentType="Application/x-msdownload"; Response.appendheader ("content-disposition","attachment; Filename="+"Coupon . jpg"); Response.ContentType="Application/octstream"; Response.CacheControl="Private"; System.IO.Stream STM=NewSystem.IO.FileStream (Server.MapPath ("~/uploadfiles/youhui/"+path), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); Response.appendheader ("Content-length", STM. Length.tostring ()); System.IO.BinaryReader BR=NewSystem.IO.BinaryReader (STM); byte[] bytes; for(Int64 x =0; x < (Br. Basestream.length/4096+1); X + +) {bytes= Br. Readbytes (4096); Response.BinaryWrite (bytes); System.Threading.Thread.Sleep (5); }
About Web download files, using data flow mode to download