国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

視頻(其他)下載+tomcat 配置編碼+圖片上傳限制大小

2019-11-14 22:11:10
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
視頻(其他)下載+tomcat 配置編碼+圖片上傳限制大小
視頻下載:前臺(tái) jsp function downVideo(value,row,index){ return '<a href="<%=basePath%>admin/video/video!fileDown.ds?uname='+row.uname+'&filepath='+value+'">下載</a>';}后臺(tái)java :action: public void fileDown() {   FileUtil.download(filepath, getRequest().getParameter("uname")+filepath.substring(filepath.lastIndexOf("."),filepath.length()), getResponse());  }FileUtil:public static void download(String filepath, String filename, HttpServletResponse response) {        response.setContentType("application/x-download;charset=utf-8");        OutputStream outp = null;        FileInputStream in = null;        try {            response.addHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes("gbk"),"ISO-8859-1"));                     in = new FileInputStream(ServletActionContext.getServletContext().getRealPath("/")+filepath);            outp = response.getOutputStream();        } catch (UnsupportedEncodingException e1) {            e1.PRintStackTrace();        } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }        byte[] b = new byte[1024];        int i = 0;        try {            while ((i = in.read(b, 0, 1024)) != -1) {                outp.write(b, 0, i);                outp.flush();            }                 } catch (IOException e) {            e.printStackTrace();        } finally {            if (in != null) {                try {                    in.close();                } catch (IOException e) {                    e.printStackTrace();                }                in = null;            }            if (outp != null) {                outp = null;            }        }    }

tomcat 配置編碼為utf-8

在tomcat servlet.xml里面 第69行加上 URIEncoding="UTF-8"    <Connector port="8080" protocol="HTTP/1.1"   URIEncoding="UTF-8"               connectionTimeout="20000"               redirectPort="8443" />

圖片上傳限制大小

<form id="financialForm" action="<%=basePath%>riskcontrol/website/review_borrow!financialUplaod.ds"  method="post"  enctype="mult
<script type="text/Javascript"> function checkusertype(){   var usertype="${login_session_key.userType}";   if(!(usertype==2||usertype==11)){    alert("只有財(cái)務(wù)風(fēng)控或者 總部客服可以上傳復(fù)審材料");    return false;   }else{    return submitFile();   } } function submitFile(){   var fileArr = document.getElementById("financialImages").files;    if(fileArr.length==0){     alert('請(qǐng)選擇上傳的圖片!');     return false;    }   for( var i=0;i<fileArr.length;i++){   var imageName=fileArr[i].name;      var extStart=imageName.lastIndexOf(".");      var ext=imageName.substring(extStart,imageName.length).toUpperCase();      if(ext!=".PNG"&&ext!=".JPEG"&&ext!=".JPG"&&ext!=".BMP"){                   alert("圖片限于PNG,JPEG,JPG,BHMP格式");                     return false;                }       var filesize = fileArr[i].size/1024;       if(parseInt(filesize)>300){        alert('圖片不能大于300KB');        return false;       }     //  $('#financialForm').submit();   }  }</script>


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 横山县| 崇明县| 玉树县| 柯坪县| 丰宁| 伊通| 台中县| 德江县| 道真| 江门市| 富顺县| 通海县| 开江县| 东阿县| 朝阳区| 庄浪县| 邹城市| 宝清县| 洮南市| 久治县| 大宁县| 驻马店市| 云林县| 宁晋县| 东明县| 鄱阳县| 确山县| 金门县| 辽宁省| 灵丘县| 伊宁县| 平舆县| 和政县| 郎溪县| 丰原市| 栾城县| 阳曲县| 正镶白旗| 云浮市| 隆回县| 龙江县|