1 protected voidUpload_click (Objectsender, EventArgs e)2 {3 stringLs_docid = httpcontext.current.request["Key"];4 if(string. IsNullOrEmpty (ls_docid))5 {6 return;7 }8 stringLs_extension =System.IO.Path.GetExtension (fpfileup.filename). ToLower ();9 stringFilePath =FpFileUp.PostedFile.FileName;Ten stringFileName =Fpfileup.filename; One if((Ls_extension! =". doc") && (ls_extension! ="docx")) A { -Page.ClientScript.RegisterStartupScript (typeof(string),"","<script>showtopmsg (' Sorry, only files in. doc or docx format! ', +, ' error ');</script>"); - return; the } - -FilePath =string. IsNullOrEmpty (fpFileUp.PostedFile.FileName)? Accessfile: This. FpFileUp.PostedFile.FileName; -Accessfile =FilePath; + //storage path for the server - stringLs_saveurl ="/docfile/"+ GYDATE.OF_GETTODAYSTR () +"/"; + stringSavepath =Htmlcomm.gf_getsavepath (); A at if(file.exists (filename)) {file.delete (filename);} - //generate a file name that is not duplicated -filename = path.getfilenamewithoutextension (filename) +"_"+ gystring.of_getnewguid () +path.getextension (fileName); -Fpfileup.saveas (Savepath +fileName); -N_create_sql LNV_ANW =NewN_create_sql ("Docanswer"); -Lnv_anw.of_addcol ("Upurl", Savepath +fileName); inLnv_anw.of_execute ("[email protected]","@docid ="+ls_docid); - toPage.ClientScript.RegisterStartupScript (typeof(string),"","<script>showtopmsg (' attachment has been uploaded! ', ' success ');</script>"); + -}
C # doc File upload