檔案上傳自動分割資訊入庫檔案讀取

2021-08-25 15:23:46 字數 2470 閱讀 3688

最近做了乙個功能,由於每逢年過節,要求匯入客戶資料的客戶越來越多。現在客戶資料超過了800萬,查詢速度明顯下降,甚至無法忍受。既然有些客戶只是為了給這些匯入的客戶傳送簡訊,而不運用其他功能,那就直接給你手機號碼的了。

首先要選擇給哪個商戶匯入他提供的手機號碼:

頁面:

<%@ page contenttype="text/html; charset=utf-8"%>

<%

string departmentsid=string.valueof(request.getattribute("departmentsid"));

int corpsid=(integer)request.getattribute("corpsid");

session.setattribute("corpsid",corpsid);

session.setattribute("departmentsid",departmentsid);

session.setattribute("pagecontext",pagecontext);

%>

%6ȷ手機號碼--選擇txt檔案

選擇txt檔案(*必填項)  必須上傳txt檔案,而且每個手機號碼佔一行,大小不要超過50m

方法:

}接著是上傳檔案:

//mysql 連線初始化

try

//檔案表單

else if(!fi.isformfield())

string filepath = fi.getname();//獲得檔案絕對路徑

system.out.println("檔名稱:"+filepath);

int a=filepath.lastindexof("\\");

system.out.println("a="+a);

int b=filepath.lastindexof(".");

string fn=filepath.substring(b);//獲取檔案的字尾名

if(!fn.equals(".txt"))

system.out.println("filepath="+filepath+",fn="+fn);

string f=dateutils.getdate("yyyymmddhhmmss");//以日期命名

try

} catch (exception e)

}count++;

} } catch (fileuploadexception e)

request.setattribute("message",this.msg_success);

request.setattribute("redirecturl", requesturi+".do?method=list");

return new modelandview(this.successview);

}在上傳的過程中按行分割上傳的檔案:

private boolean splitfile(int rows,string sourcefilepath,string targetdirectorypath,string filename,company company,department department)

if(targetfile.exists())

}else

tryi++;

tempdata = br.readline();

}system.out.println("共迴圈"+count+",i="+i);

if((i-1)%rows!=0)

system.out.println("檔案分割結束,共分割成了"+s+"個檔案");

}catch(exception e)

boolean istrue=insertdata(truename,sourcefile.getname(),targetfile.getabsolutepath(),company,department,s);

if(!istrue)

return iscontinue;

}

檔案上傳自定義上傳路徑

2019 11 21 檔案上傳自定義上傳路徑,並且根據返回的url可以進行訪問 檔案上傳路徑 file 虛擬路徑,對外展示 staticaccesspath file 本地測試真實路徑,可以改為伺服器tomcat中路徑 fileupload f fileupload package io.renre...

php檔案上傳 自己寫的

單上傳 author buhuan param string file form name form表單的上傳檔案欄位的名稱 name屬性 param string upload path 上傳的資料夾絕對路徑 param string web path 上傳後檔案相對於 根目錄的相對路徑 para...

vant Uploader 檔案上傳,自定義引數

uploader在多元件中傳參index,方便val賦值 由伺服器返回的url位址 template uploader after read afterread itm v model itm.imgs max count maximgcount disabled disabled js itm是傳...