前端和后端的區(qū)別 java中怎么把文件上傳到服務器的指定路徑?
java中怎么把文件上傳到服務器的指定路徑?字符串realpath=ServletActionContext.getServletContext(). Getrealpath(“/upload”)//
java中怎么把文件上傳到服務器的指定路徑?
字符串realpath=ServletActionContext.getServletContext(). Getrealpath(“/upload”)//獲取服務器路徑字符串[]targetfile name=UploadFile name for(int i=0 i<)上傳.長度i){ File target=新文件(realpath,targetFileName[i])FileUtils.copyFile文件(upload[i],target)//這是一個文件復制類。Copyfile()包含IO操作。如果不使用這個類,也可以自己為IO復制文件編寫一個類。Private file[]upload//實際上傳的文件Private string[]uploadcontenttype//文件的內(nèi)容類型Private string[]uploadfilename//上傳文件名的三個參數(shù)必須這樣命名,因為文件上傳控件默認封裝這三個參數(shù),他們應該有行動起來的方法!