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相结合而成的文件上传插件,其功能非常强大.以前在项目中用过几次,但它的配置参数太多了,用过后就忘记怎么用了,到以后要用时又得到官网上看它的文档,真是太烦了.所以 ...
随机推荐
- hibernate 中id生成策略
数据库的设计和操作中,我们通常会给表建立主键. 主键,可以分为自然主键和代理主键. 自然主键表示:采用具有业务逻辑含义的字段作为表的主键.比如在用户信息表中,采用用户的身份证号码作为主键.但是这样一来 ...
- pfx 转 snk
最近用 fody 加在c#工程内,但是签名只认snk ,好像是mono cecil的问题,都不认pfx,重新生成snk文件,publishkey又要变了, 底层dll引用的地方太多,要改好多cspro ...
- Sass结合Modernizr的使用方法
Modernizr在初始化的时候会首先找寻class=“no-js”的元素: <!DOCTYPE html> <html class="no-js"> &l ...
- BZOJ_1024_[SHOI2008]_生日快乐_(dfs)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1024 给出一个\(x*y\)的距形,要求平行于边切,最终切成\(n\)个面积相等的小距形,求长 ...
- AssetManager asset的使用
Android 系统为每个新设计的程序提供了/assets目录,这个目录保存的文件可以打包在程序里./res 和/assets的不同点是,android不为/assets下的文件生成ID.如果使用/a ...
- LeetCode Binary Tree Preorder Traversal 先根遍历
题意:给一棵树,求其先根遍历的结果. 思路: (1)深搜法: /** * Definition for a binary tree node. * struct TreeNode { * int va ...
- <一>SQL优化1-4
第一条:去除在谓词列上编写的任何标量函数 --->在select 显示列上使用标量函数是可以的.但在where语句后的过滤条件部分对列使用函数,需要考虑.因为执行sql的引擎会因为 ...
- MyBatis学习 之 二、SQL语句映射文件(1)resultMap
目录(?)[-] 二SQL语句映射文件1resultMap resultMap idresult constructor association联合 使用select实现联合 使用resultMap实 ...
- 打通ssh的方法
为了实现密码免输入,可以在安全的内网环境中打通ssh.linux和cygwin均可,步骤如下: 由A机去B机.在A生成密钥:ssh-keygen -t rsa,一路回车 将A的~/.ssh/id_rs ...
- YUV采样及存储格式
YUV,分为三个分量,“Y”表示明亮度(Luminance或Luma),也就是灰度值:而“U”和“V” 表示的则是色度(Chrominance或Chroma),作用是描述影像色彩及饱和度,用于指定像素 ...