一、上传按钮样式

1.1id="show_filebutton"是显示给用户操作按钮,id="filebutton"是flash上传按钮完成用户上传操作。id="show_filebutton"按钮样式不需要变,只需要将id="filebutton"按钮覆盖在id="show_filebutton"按钮上面就行了。

1.2uploadify会生成自己的html元素class="swfupload"

<html>

<body>

<head>

<style>

.swfupload{background:red;}  //设置flash上传按钮背景颜色。可以看到按钮方便设置宽高等css属性

.swfupload{width: 120px;height: 35px; top: -35px;left: 50px;opacity:0;}    //flash上传按钮覆盖美工提供过来的上传按钮,uploadify上传按钮本身就是透明不可见,这样方便我们覆盖在按钮上面达到效果

</style>

</head>

<button id="show_filebutton" type="button">导入数据文件</button>
<button type="button" id="filebutton"></button>

</body>

</html>

二、绑定上传按钮事件

$(document).ready(function(){

$("#filebutton").uploadify({
'swf' : '/plugin/uploader/uploadify.swf',
'uploader' : '/simple/upload.do',
'buttonClass' : 'upload',
'buttonText' : '',
'width': 'auto',
'queueID' : "upload_queue",
'auto' : false,
'fileObjName' : 'uploads',
'multi' : false, //多文件上传
'fileSizeLimit' : 2048 , //限制文件的大小,默认单位是KB
'uploadLimit' : 1,
'fileTypeDesc' : '支持资源格式:',
'fileTypeExts' : '*.xls;*.xlsx;',
'onUploadStart' : function(file){
$('#filebutton').uploadify("settings", "formData", {para:1});
},
'onUploadSuccess' : function(file, data, response) {
var uploadLimit = $("#filebutton").uploadify('settings', 'uploadLimit'); //get
$("#filebutton").uploadify('settings', 'uploadLimit', uploadLimit+1); //set
$("#downloadfilename").val(data);
}
});

});

java上传代码

public class Upload(){

public void uploadImage(){
UUID uuid = UUID.randomUUID();
String sysPath = getSession().getServletContext().getRealPath("");
File tempFile = new File(sysPath+"/upload/temp/");
if(!tempFile.exists()){
tempFile.mkdirs();
}
UploadFile upfile = getFile("image");
if(upfile != null){
File file = upfile.getFile();
String fileName = uuid+"_"+file.getName();
String filepath = "/upload/temp/"+fileName;
file.renameTo(new File(sysPath+filepath));
setAttr("filepath", filepath);
}
renderJson();
}

}

uploadify上传的更多相关文章

  1. CI框架如何在主目录application目录之外使用uploadify上传插件和bootstrap前端框架:

    19:29 2016/3/10CI框架如何在主目录application目录之外使用uploadify上传插件和bootstrap前端框架:项目主路径:F:\wamp\www\graduationPr ...

  2. Uploadify 上传文件插件详解

    Uploadify 上传文件插件详解 Uploadify是JQuery的一个上传插件,实现的效果非常不错,带进度显示.不过官方提供的实例时php版本的,本文将详细介绍Uploadify在Aspnet中 ...

  3. 使用uploadify上传控件无法进入后台问题分析

    分别在.net mvc 和java struts2中使用到 uploadify上传 文件,遇到同样的问题,选中文件上传后,文件无法上传,打上断点后发现没有进入后台. 逐步断点发现 项目共同点是加入了 ...

  4. Uploadify上传Excel到数据库

    前两章简单的介绍了Uploadify上传插件的基本使用和相关的属性说明.这一章结合Uploadify+ssh框架+jquery实现Excel上传并保存到数据库.         以前写的这篇文章 Jq ...

  5. 文件上传~Uploadify上传控件~续(多文件上传)

    对于Uploadify文件上传之前已经讲过一次(文件上传~Uploadify上传控件),只不过没有涉及到多文件的上传,这回主要说一下多个文件的上传,首先,我们要清楚一个概念,多文件上传前端Upload ...

  6. uploadify上传控件中文的乱码解决办法

    uploadify上传控件中文的乱码解决办法 网站用的gb2312的编码,用uploadify上传控件上传中文时在IE能部分成功,FF,Chrome则完全失败,查找了一天原因,结果发现是页面编码问题, ...

  7. jquery的uploadify上传jsp+servlet

    1.准备材料:下载jquery.uploadify上传js   注意:这个上传在firefox下会出现问题如果你在项目中加了拦截器,因为session会丢失,所以你可以传参的时候带上你所需要的条件,在 ...

  8. 解决Uploadify上传控件加载导致的GET 404 Not Found问题

    今天在项目发用到Uploadify上传, 发现在打开页面时会有一多余的请求,由于路由没有设置这个,导致404错误,能搜索查到以下解决的方法 <Uploadify v3 bug. Unecessa ...

  9. uploadify上传文件(2)--基础语法

    隔了好久,因为最近搬家,离开从小生活的城市,来到杭州.找工作.找房子等诸多事宜耽误了这篇文章许久.今天难得闲暇在旅馆中完成uploadify上传文件系列的第二篇--uploadify使用的基础语法. ...

随机推荐

  1. C++11的new concepts (move semantic)

    MoveConstructible 和MoveAssignable MoveConstructible Specifies that an instance of the type can be mo ...

  2. html5 placeholder

    placeholder是html5<input>标签的一个属性,placeholder 属性提供可描述输入字段预期值的提示信息(hint).该提示会在输入字段为空时显示,并会在字段获得焦点 ...

  3. R——启程——豆瓣影评分析

    专业统计的我,自然免不了学R的,今天仔细看了这篇教程(感谢学姐的推荐@喜欢算法的女青年),就学着用R仿照着做一个,作为R语言学习的起点吧. 影评数据是用python爬的,之后会在python爬虫系列补 ...

  4. 【LEETCODE OJ】Single Number II

    Problem link: http://oj.leetcode.com/problems/single-number-ii/ The problem seems like the Single Nu ...

  5. jQuery中.parent和.parents的区别

    .parent(selector) 获得当前匹配元素集合中每个元素的父元素,由选择器筛选(可选). .parents(selector) 获得当前匹配元素集合中每个元素的祖先元素,由选择器筛选(可选) ...

  6. UI基础:UITableView的编辑和移动

    相对UITableViiew进行编辑,必须设置代理,让代理遵循UITableViewDataSource和UITableViewDelegate协议.因为需要代理实现协议中几个必须的方法. UITab ...

  7. Raising Modulo Numbers_快速幂取模算法

    Description People are different. Some secretly read magazines full of interesting girls' pictures, ...

  8. 完美解决方案,可排除DATASET不支持System.Nullable错误

    完美解决方案,可排除DATASET不支持System.Nullable错误 using System; using System.Collections.Generic; using System.L ...

  9. Js验证userAgent是否来自手机端

    function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...

  10. 将List转换成DataTable

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...