<summary>///uploading images///</summary>///<param name= "FileUpload" > uploaded controls </param>///<param Name= "folder" > Folders to be stored (to be present on the server) </param>///<param name= "ImageName" > Picture name </param>///< Returns></returns>public string Uploadimage (FileUpload FileUpload, String folder, String imageName) {Boolean F Ileok = false; String Path = Server.MapPath ("~/" + folder + "/"); if (fileupload. HasFile) {String fileextension = System.IO.Path.GetExtension (fileupload. FileName). ToLower (); String[] allowedextensions = {". gif", ". png", ". jpeg", ". jpg"}; for (int i = 0; i < allowedextensions.length; i++) {if (fileextension = = Allowedextensions[i]) {FileOK = true; }}} else {return "Please select the file to upload! "; } if (FileOK) {try {string imagespath = path + ImageName + path.getextension (FILEUPLOAD.F Ilename); FileUpload. Postedfile.saveas (Imagespath); Return "Upload successful! "; } catch {return ' upload failed! "; }} else {return ' can only upload. gif,. png,. jpeg,. jpg and other types of pictures! "; }}
ASP-Upload Image method (leaflet)