视频(其他)下载+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 ...
随机推荐
- Paxos算法小结
转自不正直的绅士,因百度空间迁移,无法注明出处,我从其google搜索引擎中的cache进行的copy. 不正直的绅士 是跟我一起工作过的非常有才的一个青年才俊. Paxos的使用非常广泛.sanlo ...
- c# 搭建服务端 传输协议(2)
在网络的数据传输中,要将需要传输的数据转换为二进制数据后传输,才能被服务端正常的接收,socket传输中,接收到的数据都会被放入byte[]中存放,所以在数据发送前,对二进制的数组进行有规律的排序,才 ...
- NYOJ-252 01串
01串 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有"11"子串的这样的长 ...
- VBA 开发学习--基础语法2
VBA中的运算符 算数运算符及其作用 + 求两个数的和 - 求两个数的差:求一个数的相反数 * 求两个数的积 / 求两个数的商(保留小数位 5/2=2.5) \ 整除 (保留整数位 ...
- xcode -饼状进度条
界面搭建 创建一个画饼状的类 eatView 集成UIView #import "eatView.h" @implementation eatView // Only overr ...
- Dearmweaver CS6 如何添加emmet 插件
一.关于emmet插件 已经接触前端工具的小伙伴们早听说过这个插件的鼎鼎大名了吧,emmet可以说是前端工程师的利器,就连老牌dreamweaver 都可以支持,我们怎么好意思拒绝这个好东西呢? 有 ...
- WCF遇到Oracle问题
解决 选中下图中对网站和项目使用IIS….64位版
- Java随机数生成原理--转稿
1.Math库里的static(静态)方法random() 该方法的作用是产生0到1之间(包括0,但不包括1)的一个double值. double rand = Math.random(); 2.通过 ...
- Java threadpool机制深入分析
简介 在前面的一篇文章里我对java threadpool的几种基本应用方法做了个总结.Java的线程池针对不同应用的场景,主要有固定长度类型.可变长度类型以及定时执行等几种.针对这几种类型的创建,j ...
- LeetCode 1. twoSums
C++: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int&g ...