DataTable dtimages =NewDataTable (); stringfilepath =FileUpload1.PostedFile.FileName; //Check if there are any files to upload if( This. Fileupload1.hasfile) {if( This. FileUpload1.PostedFile.ContentLength >3096000) {webmsg.message ("file cannot exceed 3m!"); return; } filepath=Fileupload1.filename; stringfiletype = System.IO.Path.GetExtension (filepath). ToLower ();//Get suffix name if(filetype = =". jpg"|| filetype = =". PNG"|| filetype = =". gif") {DateTime dt=DateTime.Now; stringfilename =string. Format ("{0:YYYYMMDDHHMMSSFFFF}", DT) +filetype; stringSavepath = Server.MapPath (".. /studentcenter/upload/") +filename; FileUpload1.PostedFile.SaveAs (Savepath); stringImgurl =".. /studentcenter/upload/"+filename; if(session["UPLOAD"] ==NULL) {DTIMAGES.COLUMNS.ADD ("Imgurl",typeof(Object)); DTIMAGES.ROWS.ADD (New Object[] {imgurl}); session["UPLOAD"] =dtimages; } Else{dtimages= session["UPLOAD"] asDataTable; DTIMAGES.ROWS.ADD (New Object[] {imgurl}); session["UPLOAD"] =dtimages; } dlst_img. DataSource= session["UPLOAD"]; Dlst_img. DataBind (); } Else{webmsg.message ("please upload a jpg or PNG or GIF picture Format!"); } }
Upload multiple photos with session temporary storage