视频(其他)下载+tomcat 配置编码+图片上传限制大小
视频下载:
前台 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 配置编码+图片上传限制大小的更多相关文章
- 百度UEditor在线编辑器的配置和图片上传
前言 最近在项目中使用了百度UEditor富文本编辑器,配置UEditor过程中遇到了几个问题,在此记录一下解决方案和使用方法,避免以后使用UEditor出现类似的错误. 基本配置 一.下载UEdit ...
- 百度开源富文本编辑器 UEditor配置:图片上传和文件上传独立使用方法
使用UEditor编辑器自带的插件实现图片上传和文件上传功能,这里通过配置UEditor单独使用其内置的第三方插件swfupload来实现图片和文件的上传,通过对UEditor配置轻松实现图片批量上传 ...
- 配置django图片上传与保存展示
近来在研究django,发现有好多好玩的功能,比如图片上传,以前处理这个比较麻烦,现在我们来看看如何来处理图片上传与保存 1.在数据库设计的时候需要配置upload_to image = models ...
- 富文本编辑器CKeditor的配置和图片上传,看完不后悔
CKeditor是一款富文本编辑器,本文将用极为简单的方式介绍一下它的使用和困扰大家很久的图片上传问题,要有耐心. 第一步:如何使用 1.官网下载https://ckeditor.com/ckedit ...
- 关于UEditor的使用配置(图片上传配置)
接到新需求,需要在平台上使用富文本编辑器,我这次选择了百度的UEditor 在官网上下载l.net版本的1.4.3开发版本 http://ueditor.baidu.com/website/downl ...
- tomcat 下 base64图片上传超过2m的解决方案
方案一: tomcat部署下默认post请求提交参数大小为2M左右,超过这个大小,就会传值不成功 要使post请求参数无大小限制,需要在server.xml上修改,如下: <Connector ...
- php base64编码图片上传七牛
上网上找了好几个例子 都是自己写curl上传 感觉七牛这么多年了不应该sdk不提供一个方法 然后试 试 试 显示put 方式 上传上去 就是个字符串 后来换成文件上传方法 putFile 成了 不废话 ...
- 一百三十五:CMS系统之UEditoe编辑器集成以及配置将图片上传到七牛
富文本编辑框,选择UEditor 下载地址:http://ueditor.baidu.com/website/download.html 使用说明:http://fex.baidu.com/uedit ...
- vue+element-ui upload图片上传前大小超过4m,自动压缩到指定大小,长宽
最近项目需要实现一个需求,用户上传图片时,图片大小超过4M,长宽超过2000,需要压缩到400k,2000宽高.在git上找到一个不错的方法,把实现方法总结一下: 安装image-conversion ...
随机推荐
- 跟我一起学extjs5(16--各种Grid列的自己定义渲染)
跟我一起学extjs5(16--各种Grid列的自己定义渲染) Grid各列已经可以展示出来了.列的类型包含字符型,整型,浮点型,货币型,百分比型,日期型和布尔型,我自己定义了各种类型 ...
- Effective C++ Item 36 绝不又一次定义继承而来的 non-virtual 函数
本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie 经验:绝对不要又一次定义继承而来的 non-virtual 函数 --> Item 7 ...
- Linux ln命令具体解释及使用
Linux ln命令具体解释及使用 ln是linux中一个很重要命令,它的功能是为某一个文件在另外一个位置建立一个不同的链接,这个命令最经常使用的參数是-s,详细使用方法是:ln –s 源文件 目标文 ...
- NYOJ128 前缀式计算(栈的运用)
题目信息: http://acm.nyist.net/JudgeOnline/problem.php? pid=128 + 2 * + 3 4 5的值就是 37,详见输入输出. 输入 有多组測试数据, ...
- CSS3六边形
<!DOCTYPE html> <!-- saved from url=(0043)http://dbox.whosemind.net/demo/liufang.html --> ...
- s2sh遇到的问题
一:ids for this class must be manually assigned before calling save() "类名.hbm.xml"映射文件中< ...
- JavaScript知识(一)
首先想为大家分享两句话: 侧耳听智慧,专心求聪明,呼求明哲,扬声求聪明.——箴言2:2-3 你要保守你心,胜过保守一切,因为一生的果效,是由心发出.——箴言 4:23 ...O(∩_∩)O...今天学 ...
- errorPlacement的位置问题
做一个前端的验证,使用了JQUERY.Validate 在errorPlacement上纠结了半天: 百度大多数都是一个答案: errorPlacement: function(error, elem ...
- HOJ1008
#include<iostream> using namespace std; int main(){ ; ; ){ ; ; numTemp = N; ) && count ...
- intellj idea 如何设置类头注释和方法注释
intellj idea 如何设置类头注释和方法注释 intellj idea的强大之处就不多说了,相信每个用过它的人都会体会到,但是我们也会被他的复杂搞的晕头转向,尤其刚从ecl ...