<%@ page contentType="text/html;charset=utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>SWFUpload Demos - External Interface Demo</title>
<link href="swfupload/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="swfupload/fileprogress.js"></script>
<script type="text/javascript" src="swfupload/handlers.js"></script>
<script type="text/javascript" src="swfupload/jquery.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function() {
var settings = {
flash_url : "<%=request.getContextPath()%>/swfupload/swfupload.swf",
upload_url: "fileUpload.action", // Relative to the SWF file
post_params: { "fileFileName": '<%= request.getParameter("fileFileName") %>' },
file_size_limit : "100 MB",
file_types : "*.*",
file_post_name:"file",//与后台要接受的问价相对应 默认是filedata
file_types_description : "All Files",
file_upload_limit : 100,
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel1",
startButton:"startButton",
percentage:"percentage"
},
debug: false,
// Button Settings
button_image_url : "<%=request.getContextPath()%>/swfupload/XPButtonUploadText_61x22.png", // Relative to the SWF file
button_placeholder_id : "spanButtonPlaceHolder",
button_width: 61,
button_height: 22,
// The event handler functions are defined in handlers.js
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete
};
swfu = new SWFUpload(settings);
};
</script>
</head>
<body>
<div id="content">
<form id="form1" method="post" enctype="multipart/form-data">
<div class="fieldset flash" id="fsUploadProgress">
<span class="legend">上传队列</span>
</div>
<div id="divMovieContainer">
<span id="spanButtonPlaceHolder"></span>
<input type="button" value="开始上传" id="startButton" onclick="swfu.startUpload();" disabled="disabled" />
<input id="btnCancel1" type="button" value="取消" onclick="cancelQueue(swfu);" disabled="disabled" />
</div>
</form>
</div>
</body>
</html>
public class FileUploadAction extends ActionSupport {
private File file;
private String fileFileName;
/**
* @return the file
*/
public File getFile() {
return file;
}
/**
* @param file the file to set
*/
public void setFile(File file) {
this.file = file;
}
/**
* @return the fileFileName
*/
public String getFileFileName() {
return fileFileName;
}
/**
* @param fileFileName the fileFileName to set
*/
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String upload() {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(file);
String path = ServletActionContext.getServletContext().getRealPath("upload");
File f = new File(path, fileFileName);
os = new FileOutputStream(f);
byte[] buffer = new byte[1024];
int temp = 0;
while ((temp = is.read(buffer)) != -1) {
os.write(buffer, 0, temp);
}
System.out.println(fileFileName);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return SUCCESS;
}
}
分享到:
相关推荐
java+struts+swfupload文件上传下载 下载后可以直接运行
JAVA+Struts2+swfupload上传下载,下载即可运行,支持多文件上传,Java代码有详细的代码注释。
ext struts2 swfupload 跨域文件上传
资源绝对可以用,经本人测试。。 原理:一次可以全选N个文件,然后将文件放入队列中,依次单个文件上传。可以设定上传文件大小类型,只需要更改路径就可以了
NULL 博文链接:https://longhahe.iteye.com/blog/1756339
本示例解决了strut2+swfupload+extjs4文件上传过程中,后台struts接收不到上传文件的问题。而这个问题如果用servlet做后台可能就不存在。开发者可以用本例源码移植到自己项目中使用 。
利用Struts2上传文件时有时会速度过慢,这时候如果没有进度条显示的话会使得界面很不友好,所以我找了很多资料并调试成功,该文件就是项目文件,解压后直接用myeclipse8.5打开运行即可!
SWFUpload上传组件的一个完整的例子,后台由Struts2完成,有上传进度显示,可以多文件上传,如果你想使用SWFUpload组件但还不知道怎样使用,可以下载下来运行一下试试,看一下源码就知道了。
一个swfupload+struts2实现多文件上传的案例。
SwfUpload多文件上传 struts1实现控制层
自己写的一个DEMO,实现多文件上传,里面的样式使用的swfupload中的多文件上传的样式,只是实现了struts2+swfuplaod上传,喜欢的可以看看,
使用struts2整合swfupload,实现包含进度条的文件上传模块 SWFUpload的主要特点 * 可以同时上传多个文件; * 类似AJAX的无刷新上传; * 可以显示上传进度; * 良好的浏览器兼容性; * 兼容其他JavaScript库 (例如:...
swfupload 多文件上传 选择多个文件 无刷新上传 使用框架struts2
swfupload 上传 多文件 java 支持多文件上传,只需要在配置文件配置正确即可,后台是,struts2
利用swfupload结合struts2实现的一个上传mp3和mp4文件,并可以在页面上用html5进行播放,本例只是自己动手写的一个小例子。注意:为了节省资源,例子中并未包含struts2的jar,需要手动添加struts2用到的jar包
用的最新版本的 swfuploadv2.2.0.1,现在已经出了2.5版本的,但是还是测试版本的,可能会不稳定,所以我做了swfuploadv2.2.0.1这个版本的,大文件上传,90MB的文件5秒内就传好了 很快,效果很好用过就知道了
swfupload与struts2整合、完整java实例、
本项目是struts2和swfupload结合,实现单个文件上传、上传后预览(index.jsp),和批量上传(multiple.jsp),里面都有代码注释和一个整理的说明文档(SWFUpload说明文档),讲的非常非常详细,都是本人亲自整理。...
Java版 swfupload 上传显示 文件大小,速度,剩余时间 进度条 ssh2 开源 文件上传 下载 只要把下载的文件集成到 ssh2 的项目里面去就可以了。