视频下载:
前台 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. opennebula kvm attach disk

    openNebula hotPlug disk or nic 网络检索关键字(Network search keywords) 208.117.233.122 virsh attach disk vi ...

  2. MFC的命令行

    一个程序,我们通过输入不同的命令行参数,就可以实现一个可执行文件,多种功能,通过命令行来控制它的行为,例如,我们在控制台的时候,就是遇到最多的,如一个exe程序,加入为test..exe,我们可以设置 ...

  3. jQuery中$.each的用法

    jQuery中$.each的用法   本文导读:jQuery中each()函数是基本上所有的框架都提供了的一个工具类函数,通过它,你可以遍历对象.数组的属性值并进行处理.jQuery提供的each方法 ...

  4. Unity5UGUI 官方教程学习笔记(四)UI Image

    Image Source image:源图片  需要显示的图片 Color:颜色  会与图片进行颜色的混合 Material:材质 Image Type:  Simple   精灵只会延伸到适合Rec ...

  5. C++_基础_类和对象

    内容: (1)引用 (2)类型转换 (3)C++社区给C程序员的建议 (4)面向对象编程的概念 (5)类和对象 (6)构造函数 (7)初始化列表及其必要性 1.引用1.1 指针和引用的使用说明(1)指 ...

  6. SGU 506.Subsequences Of Substrings

    求一个串S有多少子串subS满足s是subS的子序列.len(S)<=100000, len(s)<=100 直接扫一遍... ------------------------------ ...

  7. IOS-将长文字转化成图片方法

    我们在看微博时,会看到一些长图片上的显示文章,现在就介绍下如何实现.分析下还是很简单的,总结如下:1.计算文字区域的高 2.利用UIGraphics图形上下文方法来实现 3.验证方法:UIImageW ...

  8. JS 操作日期

    var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-???? ...

  9. JS中的this都有什么作用?

    1.全局代码中的this  是指向全局对象,在浏览器中是window alert(this) //window 2.作为单纯的函数调用: function fooCoder(x) { this.x = ...

  10. 静态资源库CDN服务

    使用静态资源库可以访问线上资源文件,比如jquery库.bootstrap库.使用百度静态资源库的居多,但是发现百度暂时不支持https协议,bootcdn是一个不错的选择. 百度静态资源公共库 优点 ...