if (fileupload.postedfile! = null) {// addTo is the property you want to add, and referencefile shows the file name for the file. INT i = nam.lastIndexof ("."); // Get file extension String newext = nam.substring (i); // Here I automatically named files according to the date and file size, make sure the file name does not repeat DateTime Now = Datetime.now; string newname = now.dayofyear.tostring () fileupload.postedfile.contentLength.toString (); // Save the file to the directory you want, here is the UPLOAD directory of the IIS root. You can change. // Note: I will use server.mappath () to take the relative directory of the current file. In ASP.NET "/" must be replaced with "//", change "UPLOAD //" to "// Upload //" It became the absolute directory of the current file, fileupload.postedfile.saveas ("UPLOAD //" newname newext)); // Get this file related properties: file name, file type, file size / /fname.text=myfile.postedfile.FileName; //fenc.text=myfile.postedfile.contentTy; //fsize.text=myfile.postedFile.contentLength.toString (); // The following is generating thumbnails system.drawing. Image Image, AnewImage; Int Width, Newheight; Image = System.drawing.Image.FromFile (Server.MAppath ("UPL oad / " newname.ToString () newext.ToString ())); System.Drawing.Image.GetThumbnailImageAbort callb = new System.Drawing.Image.GetThumbnailImageAbort (ThumbnailCallback); width = image.Width; height = image.Height ; if (firstpageshow.SelectedValue.ToString () == "1" && fenlei.SelectedValue.ToString () == "5") {newwidth = 203; newheight = 86; newheight = height * newwidth / width;} else if (isweekman .SelectedValue.toString () == "1") {newWidth = 171; newHeight = 111; newheight =
height * newwidth / width;} else if (firstpageshow.SelectedValue.ToString () == "1" && fenlei.SelectedValue.ToString () == "3") {newwidth = 171; newheight = 111; newheight = height * newwidth / width;} else {newwidth = 62; newheight = 80; newheight = height * newwidth / width;} aNewImage = image.GetThumbnailImage (newwidth, newheight, callb, new System.IntPtr ()); aNewImage.Save (Server.MapPath ( "UPLOAD / /" "Small _" newname newext)); Image.dispose (); // Generate thumbnails generated and saved, save names in prior to adding a small_. Pic = "UPLOAD /" NewName.toAMTRING () newext.toString (); smallpic = "Upload / small _" newname.toString () newext.toString ();}