swfupload用法总结
<script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/swfupload.queue.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/fileprogress.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/handlers.js" type="text/javascript"></script>
<link href="${base}/thirdparty/swfupload/process.css" rel="stylesheet" type="text/css"/>
<#include "/common/image_upload.html"/>
<@e.text label="认证通过图标" id="uploadImgPath1" class="dfinput" name="icon" readonly="readonly"/>
<@e.text label="图片路径" id="uploadFileText1" size="14" class="dfinput" />
<input type="file" id="uploadFile1" size="14" onchange="$('#uploadFileText1').val(this.value)"/>
<br/>
<@e.hidden id="mark1" value="false"/>
<@e.button class="upload-button" onclick="upload(1);" value="上传"/>
<br/>
<a title="标题图1" id="preBigImg1" class="cmcss" href="${base}/${(mmiGroupBanner1)!}" style="margin-left:87px;margin-top:10px;" >
<img id="preImg1" style="width:100px;height:70px;background-color:#CCCCCC;" maxWidth2="200" />
</a>
<@e.text label="认证不通过图标" id="uploadImgPath2" class="dfinput" name="xicon" readonly="readonly"/>
<@e.text label="图片路径" id="uploadFileText2" size="14" class="dfinput" />
<input type="file" id="uploadFile2" size="14" onchange="$('#uploadFileText2').val(this.value)"/>
<br/>
<@e.hidden id="mark1" value="false"/>
<@e.button class="upload-button" onclick="upload(2);" value="上传"/>
<br/>
<a title="标题图2" id="preBigImg2" class="cmcss" href="${base}/${(mmiGroupBanner2)!}" style="margin-left:87px;margin-top:10px;" >
<img id="preImg2" style="width:100px;height:70px;background-color:#CCCCCC;" maxWidth2="200" />
</a>
package cn.com.yhxl.jhahi.action.admin; import java.util.Locale; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FilenameUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import cn.com.yhxl.basic.entity.ms.MsSystemConfig;
import cn.com.yhxl.basic.service.ms.IMsSystemConfigService;
import cn.com.yhxl.common.upload.FileRepository; @Controller
public class FileUploadAct { private static final Logger log = LoggerFactory.getLogger(FileUploadAct.class);
private static final String RESULT_PAGE = "/common/iframe_upload"; @RequiresPermissions("file:swfupload")
@RequestMapping(value = "/file/o_swfupload.do", method = RequestMethod.POST)
public String swfAttachsUpload(String root,Integer uploadNum, @RequestParam(value = "uploadFile", required = false) MultipartFile file,HttpServletRequest request, HttpServletResponse response,ModelMap model) throws Exception { MsSystemConfig sc = scService.get();
String origName = file.getOriginalFilename();
String ext = FilenameUtils.getExtension(origName).toLowerCase(Locale.ENGLISH);
String fileUrl = "";
try {
if(ext.equalsIgnoreCase("flv") || ext.equalsIgnoreCase("mp4") || ext.equalsIgnoreCase("f4v")){
fileUrl = fileRepository.storeByExtVideo(sc.getScVideoUploadPath(), ext, file);
fileUrl = fileUrl.replace(sc.getScVideoUploadPath(), sc.getScVideoPrefixUrl());
}else if(ext.equalsIgnoreCase("bmp") || ext.equalsIgnoreCase("png") || ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")){
fileUrl = fileRepository.storeByExt(sc.getScPhotoUploadPath(), ext, file);
}else{
fileUrl = fileRepository.storeByExt(sc.getScFileUploadPath(), ext, file);
}
// 加上部署路径
//System.out.println("fileUrl="+fileUrl); //fileMng.saveFileByPath(fileUrl, origName, false);
model.addAttribute("attachmentPath", fileUrl);
model.addAttribute("uploadPath", fileUrl);
model.addAttribute("uploadNum", uploadNum);
return RESULT_PAGE;
} catch (Exception e) {
log.error("文件上传发生错误", e);
model.addAttribute("error", e.getMessage());
}
return RESULT_PAGE; } @Autowired
protected FileRepository fileRepository;
@Autowired
private IMsSystemConfigService scService;
}
前台上传
修改<#include "/common/image_upload.html"/>文件
<script type="text/javascript">
//上传图片
function upload(n) {
var of = $("#uploadFile"+n);
//检查是否选择了图片
if(of.val()=="") {
alert("<@s.m "imageupload.error.noFileToUpload"/>");
return;
}
//将file移动至上传表单
$("#fileContent").empty();
$("#fileContent").append(of);
//复制一个file放至原处
$("#ufc"+n).append(of.clone().attr("value",""));
//修改属性
$("#uploadFileText"+n).attr("value","");
of.attr("id","");
of.attr("name","uploadFile");
//其他表单
$("#ufFileName").val($("#fileName"+n).val());
$("#ufWidth").val($("#zoomWidth"+n).val());
$("#ufHeight").val($("#zoomHeight"+n).val());
//先清除
$("#ufMark").val("");
$("#ufMark").val($("#mark"+n).val());
$("#uploadNum").val(n);
$("#uploadForm").submit();
}
//剪裁图片
function imgCut(n) {
if($("#uploadImgPath"+n).val()=="") {
alert("<@s.m "imageupload.error.noFileToCut"/>");
return;
}
var url = "../common/v_image_area_select.do?uploadNum="+n+"&imgSrcPath="
+$("#uploadImgPath"+n).val()+"&zoomWidth="+$("#zoomWidth"+n).val()+"&zoomHeight="+$("#zoomHeight"+n).val();
window.open(url,"imgcut","height=550, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=auto, resizable=yes,location=no, status=no");
}
//预览图片
function previewImg(n) {
var img = $("#uploadImgPath"+n).val();
if(img!="") {
if(img.indexOf("?")==-1) {
$("#preImg"+n).attr("src",img+"?d="+new Date()*1);
} else {
$("#preImg"+n).attr("src",img+"&d="+new Date()*1);
}
if(!$("#preImg"+n).attr("noResize")) {
$("#preImg"+n).css("width","auto");
$("#preImg"+n).css("height","auto");
}
} else {
$("#preImg"+n).removeAttr("src");
}
}
</script>
<form id="uploadForm" action="../doctor/o_swfupload.jhtml" method="post" enctype="multipart/form-data" target="hiddenIframe" style="display:none;width:0px;height:0px;">
<span id="fileContent"></span>
<input id="ufWidth" type="hidden" name="zoomWidth"/>
<input id="ufHeight" type="hidden" name="zoomHeight"/>
<input id="ufFileName" type="hidden" name="fileName"/>
<input id="ufMark" type="hidden" name="mark"/>
<input id="uploadNum" type="hidden" name="uploadNum"/>
</form>
<iframe name="hiddenIframe" frameborder="0" border="0" style="display:none;width:0px;height:0px;"></iframe>
@RequestMapping(value = "/o_swfupload.jhtml", method = RequestMethod.POST)
public String swfAttachsUpload(String root,Integer uploadNum, @RequestParam(value = "uploadFile", required = false) MultipartFile file,HttpServletRequest request, HttpServletResponse response,ModelMap model) throws Exception { MsSystemConfig sc = scService.get();
String origName = file.getOriginalFilename();
String ext = FilenameUtils.getExtension(origName).toLowerCase(Locale.ENGLISH);
String fileUrl = "";
try {
if(ext.equalsIgnoreCase("flv") || ext.equalsIgnoreCase("mp4") || ext.equalsIgnoreCase("f4v")){
fileUrl = fileRepository.storeByExtVideo(sc.getScVideoUploadPath(), ext, file);
fileUrl = fileUrl.replace(sc.getScVideoUploadPath(), sc.getScVideoPrefixUrl());
}else if(ext.equalsIgnoreCase("bmp") || ext.equalsIgnoreCase("png") || ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")){
fileUrl = fileRepository.storeByExt(sc.getScPhotoUploadPath(), ext, file);
}else{
fileUrl = fileRepository.storeByExt(sc.getScFileUploadPath(), ext, file);
}
// 加上部署路径
//System.out.println("fileUrl="+fileUrl); //fileMng.saveFileByPath(fileUrl, origName, false);
model.addAttribute("attachmentPath", fileUrl);
model.addAttribute("uploadPath", fileUrl);
model.addAttribute("uploadNum", uploadNum);
// return RESULT_PAGE;
return FrontUtils.getTplPathUrl("/WEB-INF", "common", "iframe_upload");
} catch (Exception e) {
log.error("文件上传发生错误", e);
model.addAttribute("error", e.getMessage());
}
return FrontUtils.getTplPathUrl("/WEB-INF", "common", "iframe_upload");
} private static final Logger log = LoggerFactory.getLogger(DoctorAct.class);
private static final String RESULT_PAGE = "/WEB-INF/common/iframe_upload";
@Autowired
protected FileRepository fileRepository;
@Autowired
private IMsSystemConfigService scService;
swfupload用法总结的更多相关文章
- SWFUpload
引用:http://www.cnblogs.com/2050/archive/2012/08/29/2662932.html SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非 ...
- swfupload浅谈
首先,先介绍一个swfUplod吧. SWFUpload是一个客户端文件上传工具,最初由Vinterwebb.se开发,它通过整合flash与javascript技术为web开发者提供了一个具有丰富功 ...
- 文件上传利器SWFUpload入门简易教程
凡做过网站开发的都应该知道表单file的确鸡肋. Ajax解决了不刷新页面提交表单,但是却没有解决文件上传不刷新页面,当然也有其它技术让不刷新页面而提交文件,该技术主要是利用隐藏的iFrame, 较A ...
- Flash上传组件之SWFUpload文件上传
一.什么是SWFUpload? SWFUpload是一个客户端文件上传工具,最初由Vinterwebb.se开发,它通过整合Flash与JavaScript技术为WEB开发者提供了一个具有丰富功能继而 ...
- 文件上传利器SWFUpload使用指南(转)
http://www.cnblogs.com/2050/archive/2012/08/29/2662932.html 文件上传利器SWFUpload使用指南 SWFUpload是一个flash和js ...
- SWFUpload多文件上传使用指南
SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大.以前在项目中用过几次,但它的配置参数太多了,用过后就忘记怎么用了,到以后要用时又得到官网上看它的文档,真是太烦了.所以 ...
- 【转】SWFUpload使用指南
原文出自:http://www.runoob.com/w3cnote/swfupload-guide.html SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大.以前在 ...
- jquery uploadify文件上传插件用法精析
jquery uploadify文件上传插件用法精析 CreationTime--2018年8月2日11点12分 Author:Marydon 一.参数说明 1.参数设置 $("#fil ...
- SwfUpload文件上传
SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大.以前在项目中用过几次,但它的配置参数太多了,用过后就忘记怎么用了,到以后要用时又得到官网上看它的文档,真是太烦了.所以 ...
随机推荐
- Codeforces Round #239 (Div. 2)
做了三个题,先贴一下代码...终于涨分了 A. Line to Cashier 水题 #include <iostream> #include <cstdio> #includ ...
- WebClient+Fiddler2完美搭配下载远程页面信息
WebClient可以下载远程页面信息,这个大家应该都知道,核心代码如下: WebClient web = new WebClient(); string url = String.Format(&q ...
- U盘启动格式
U盘的几种启动模式:USB-HDD.USB-ZIP.USB-HDD+.USB-ZIP+.USB-CDROM 1. USB-HDD 硬盘仿真模式,DOS启动后显示C:盘,HP U盘格式化工具制作的U盘 ...
- [反汇编练习] 160个CrackMe之019
[反汇编练习] 160个CrackMe之018. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...
- apache开源项目--Syncope
Apache Syncope is an Open Source system for managing digital identities in enterprise environments, ...
- apache开源项目 -- tomee
Apache TomEE,发音是“Tommy”,是一个经Apache.JavaEE6.Web框架认证的适配器,其在Tomcat服务器中是最强大的.Apache TomEE是由香草项目(简化常见编程任务 ...
- HDU 5430 Reflect
题意:问在一个圆形的镜面里,从任意一点发出一个光源,经n次反射回到起点的情况数是多少. 解法:直接贴题解吧…… 求1至N+1中与N+1互质的个数,即欧拉函数. 代码: #include<stdi ...
- java中的getClass()函数
Java反射学习 所谓反射,可以理解为在运行时期获取对象类型信息的操作.传统的编程方法要求程序员在编译阶段决定使用的类型,但是在反射的帮助下,编程人员可以动态获取这些信息,从而编写更加具有可移植性的代 ...
- linux命令——ll
一.ll命令 ll并不是linux下一个基本的命令,它实际上是ls -l的一个别名. Ubuntu默认不支持命令ll,必须用 ls -l,这样使用起来不是很方便. 如果要使用此命令,可以作如下修改:打 ...
- HDU 1025-Constructing Roads In JGShining's Kingdom(最长不降子序列,线段树优化)
分析: 最长不降子序列,n很大o(n^2)肯定超,想到了小明序列那个题用线段树维护前面的最大值即可 该题也可用二分搜索来做. 注意问题输出时的坑,路复数后加s #include <map> ...