[Httppost] Public String uploadimage () {// string Ss = request. form ["uploadfile"]; // return SS; httppostedfilebase uploadfile = request. files [0]; string filename = uploadfile. filename; int filesize = uploadfile. contentlength; string fileext = path. getextension (filename ). tolower (); string message = ""; if (! (Fileext = ". PNG "| fileext = ". GIF "| fileext = ". jpg "| fileext = ". JPEG ") {message =" the image type can only be GIF, PNG, JPG, JPEG "; return message;} else {If (filesize> (INT) (500*1024 )) {message = "the image size cannot exceed 500kb"; return message;} else {random r = new random (); string uploadfilename = datetime. now. tostring ("yyyymmddhhmmss") + R. next (100000,999 999) + fileext; try {string directorypath = server. map PATH ("~ /Uploadimages/"); If (! Directory. exists (directorypath) // if this folder does not exist, create this folder {directory. createdirectory (server. mappath ("~ /Uploadimages/");} uploadfile. saveas (server. mappath ("~ /Uploadimages/") + uploadfilename); message = uploadfilename; return message;} catch (exception ex) {message = ex. Message; return message ;}}}}