视频下载:
前台 jsp
function downVideo(value,row,index){
return '<a href="<%=basePath%>admin/video/video!fileDown.ds?uname='+row.uname+'&filepath='+value+'">下载</a>';
}
后台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="multipart/form-data" onsubmit="return checkusertype()" >
<input type="hidden" name="usreId" value="<%=_usreId%>" />
<input type="hidden" name="borrowId" value="<%=_borrowId%>" />
<input type="file" name="image" multiple="multiple" id="financialImages"/>
<input type="submit" value="开始上传"/>
</form>
<script type="text/javascript">

 function checkusertype(){
var usertype="${login_session_key.userType}";
if(!(usertype==2||usertype==11)){
alert("只有财务风控或者 总部客服可以上传复审材料");
return false;
}else{
return submitFile();
}
}
function submitFile(){
var fileArr = document.getElementById("financialImages").files;
if(fileArr.length==0){
alert('请选择上传的图片!');
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>

视频(其他)下载+tomcat 配置编码+图片上传限制大小的更多相关文章

  1. 百度UEditor在线编辑器的配置和图片上传

    前言 最近在项目中使用了百度UEditor富文本编辑器,配置UEditor过程中遇到了几个问题,在此记录一下解决方案和使用方法,避免以后使用UEditor出现类似的错误. 基本配置 一.下载UEdit ...

  2. 百度开源富文本编辑器 UEditor配置:图片上传和文件上传独立使用方法

    使用UEditor编辑器自带的插件实现图片上传和文件上传功能,这里通过配置UEditor单独使用其内置的第三方插件swfupload来实现图片和文件的上传,通过对UEditor配置轻松实现图片批量上传 ...

  3. 配置django图片上传与保存展示

    近来在研究django,发现有好多好玩的功能,比如图片上传,以前处理这个比较麻烦,现在我们来看看如何来处理图片上传与保存 1.在数据库设计的时候需要配置upload_to image = models ...

  4. 富文本编辑器CKeditor的配置和图片上传,看完不后悔

    CKeditor是一款富文本编辑器,本文将用极为简单的方式介绍一下它的使用和困扰大家很久的图片上传问题,要有耐心. 第一步:如何使用 1.官网下载https://ckeditor.com/ckedit ...

  5. 关于UEditor的使用配置(图片上传配置)

    接到新需求,需要在平台上使用富文本编辑器,我这次选择了百度的UEditor 在官网上下载l.net版本的1.4.3开发版本 http://ueditor.baidu.com/website/downl ...

  6. tomcat 下 base64图片上传超过2m的解决方案

    方案一: tomcat部署下默认post请求提交参数大小为2M左右,超过这个大小,就会传值不成功 要使post请求参数无大小限制,需要在server.xml上修改,如下: <Connector ...

  7. php base64编码图片上传七牛

    上网上找了好几个例子 都是自己写curl上传 感觉七牛这么多年了不应该sdk不提供一个方法 然后试 试 试 显示put 方式 上传上去 就是个字符串 后来换成文件上传方法 putFile 成了 不废话 ...

  8. 一百三十五:CMS系统之UEditoe编辑器集成以及配置将图片上传到七牛

    富文本编辑框,选择UEditor 下载地址:http://ueditor.baidu.com/website/download.html 使用说明:http://fex.baidu.com/uedit ...

  9. vue+element-ui upload图片上传前大小超过4m,自动压缩到指定大小,长宽

    最近项目需要实现一个需求,用户上传图片时,图片大小超过4M,长宽超过2000,需要压缩到400k,2000宽高.在git上找到一个不错的方法,把实现方法总结一下: 安装image-conversion ...

随机推荐

  1. js 事件之 createEvent、dispatchEvent

    //document上绑定自定义事件ondataavailable document.addEventListener('customevent', function(event) { alert(e ...

  2. JSP、JSTL、EL

    Jsp Jsp内置对象: Response.Request.Page.pageContext.session.out.application.exception.config Out->jspW ...

  3. 快照(Snapshot)

    一.定义: SNIA(存储网络行业协会)对快照(Snapshot)的定义是:关于指定数据集合的一个完全可用拷贝,该拷贝包括相应数据在某个时间点(拷贝开始的时间点)的映像.快照可以是其所表示的数据的一个 ...

  4. 2014-11-21 DHTMLX是什么

    什么是dhtmlx? dhtmlx是一套网页开发 的函式库,他提供了树状元件.数据方格组件.工具列等组件供开发 人员使用. dhtmlx组件是一个JavaScript 库,提供了一套完整的Ajax驱动 ...

  5. C# 如何从List集合当中取出子集合

    今天项目要求随机从数据库中随机取出若干条数据,放到首页.那么要如何随机取出这个子集合呢?本人向到的方法如下: 1.假设数据量很少,如我数据库中只有10条数据,而我要求随机取出8条.对于这种低数据量,大 ...

  6. SSM搭配中的web.xml的配置信息

    最近一段时间在自己学着搭建SSM框架的项目,其实这个项目自由自己不断尝试,不断失败,才能印象更深刻. 下面就说一下在项目中的web.xml的相关配置信息: <?xml version=" ...

  7. leetcode Contains Duplicate II python

    Given an array of integers and an integer k, find out whether there are two distinct indices i and j ...

  8. php install extension

    wget http://nginx.org/download/nginx-1.8.0.tar.gz wget http://nginx.org/download/nginx-1.8.0.tar.gz ...

  9. LNNVL函数使用

    显示那些佣金比例(commision)不大于20%或者为NULL的员工的信息. CREATE TABLE plch_employees (     employee_id      INTEGER P ...

  10. 一次U盘安装Ubuntu双系统实录

    准备:Win7系统(原来就在我电脑的系统) UltraISO(把系统写进U盘的工具) EasyBCD(双系统引导修复工具) 笔记本电脑(我的是联想Y470N) U盘一个 步骤: U盘准备工作: 插入U ...