一、上传按钮样式

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. Windows下LDAP服务器配置

    LDAP即轻量级目录访问协议(Lightweight Directory Access Protocol),基础知识不再赘述,本文主要记录我的配置与安装过程. LDAP for windows下载 o ...

  2. uitabbarcontroller中 在设置tab bar item的image属性后不显示问题

    开始使用ios中的UITabBarController,在给Tab Bar Item设置自定义图片的时候,遇到了问题 按照如下配置: 出来的结果确是: 实际上test24.png应该是: 纠结了很久, ...

  3. HDU 1045 - Fire Net (最大独立集)

    题意:给你一个正方形棋盘.每个棋子可以直线攻击,除非隔着石头.现在要求所有棋子都不互相攻击,问最多可以放多少个棋子. 这个题可以用搜索来做.每个棋子考虑放与不放两种情况,然后再判断是否能互相攻击来剪枝 ...

  4. uart与usart

    字面意义:UART:universal asynchronous receiver and transmitter通用异步收发器:USART:universal synchronous asynchr ...

  5. 收藏的博客--Ogre

    1.Ogre一些东西和流程深入讲解  http://blog.csdn.net/yanonsoftware/article/category/226048 2.Ogre天龙八部分析 http://bl ...

  6. hdoj-2021

    #include "stdio.h"void calculate(int number,int &a,int &b,int &c,int &d,in ...

  7. C# DataContract DataMember

    Windows Communication Foundation (WCF) uses a serialization engine called the Data Contract Serializ ...

  8. iptables_forward

    FORWARD 好了,我们接着往下走,这个包已经过了两个PREROUTING链了,这个时候,出现了一个分支转折的地方,也就是图中下方的那个菱形(FORWARD),转发!这里有一个对目的地址的判断(这里 ...

  9. 简单的多线程(活用OD解决运行时错误)

    代码源自<VC++深入详解>第15章 “多线程”,位于第563页 - 566 页. 程序的目的是展示多线程运行的效果: #include <windows.h> #includ ...

  10. Unity3D ShaderLab 使用alpha参数创建透明效果

    Unity3D ShaderLab 使用alpha参数创建透明效果 其实Unity为了方便我们的工作,为我们内置了很多参数.比如马上用到的透明功能. 准备场景新建Shader Material ,一张 ...