UPLOADFILE.POSTEDFILE.SAVEAS (PUBLIC VOID UPLOADFILE (Object Sender, Eventargs E) {// Checking Upload File is not empty IF (MyFile.PostedFile! = null ) {String nam = myfile.postedfile.FileName; // Get the last "." Index INT i = nam.lastindexof ("."); // Get file extension String newext = Nam.substring (i); // I automatically named file naming according to the date and file size, make sure the file name does not repeat DateTime now = datetime.now; string newname = now.dayofyear.tostring () myfile.postedfile.contentLength .Tostring (); // save the file to the directory you want, this is the UPLoadFiles directory of the IIS root directory // Note: I use server.mappath () to take the absolute directory of the current file. In ASP.NET "/ "Must use" // "to replace myfile.postedfile.saveas (Server.mAppath (" newname newext)); // Get related properties of this file: file name, file type, file size fname.Text = myFile.PostedFile.FileName; fenc.Text = myFile.PostedFile.ContentType; fsize.Text = myFile.PostedFile.ContentLength.ToString (); Image1.ImageUrl = "http: // localhost / web / news / uploadfiles / " newname newext;}}