Upload pictures, ask pictures 200100 pixels, size and less than 2m

xiaoxiao2021-03-06  112

Author: Internet Prodigal Box (formerly known as littlehb) http://blog.9cbs.net/littlehb/ upload pictures, pictures 200100 pixels requirements, size is less than 2M, if the picture does not meet the requirements, can not upload, or upload pictures, upload After the picture is dynamically named by the system date, the path is reserved to the database.

private void Button1_Click (object sender, System.EventArgs e) {if (File1.PostedFile.ContentType.ToUpper () IndexOf ( "IMAGE")> -. 1) {System.Drawing.Image img = System.Drawing.Image.FromStream (File1.postedfile.inputstream); int width = img.width; int Height = img.height; if (width> 200 || Height> 100 || File1.postedFile.ContentLength> 1024 * 1024 * 2) {response.write ("Do not: width =" width.toString () "
Height =" height.toString () "
size =" (this.file1.postedfile.contentLength / 1024) .tostring ( "##, ## 0.00") "k");} else {string spath = server.mappath (system.datetime.now.tostring ("YYY-MM-DD HH-MM-SS") session.SessionID ".jpg"); this.file1.postedfile.saveas (spath); Response.write ("Save Success");}} else {response.write ("Please select a picture file!");}}

转载请注明原文地址:https://www.9cbs.com/read-100685.html

New Post(0)