Jfinal+DWZ使用uploadify插件实现文件上传
来源:互联网 发布:手机烟花表白软件 编辑:程序博客网 时间:2024/05/22 15:06
upload.jsp
var htmlHead="<dl><dt style='width: 120px; text-align: right;'>已上传的文件:</dt><dd id='fileHtmlBody'>";var htmlBody="";var htmlFoot="</dd></dl>";function onComplete(event, queueId, fileObj, response, data){var obj = eval( "(" + response + ")" );//转换为JSON对象htmlBody+="<div id='file_"+obj.id+"' style='height:25px;line-height:25px;'>";htmlBody+="<span style='display:none'><input type='checkbox' class='uploaded' name='fid' value='"+obj.id+"' checked/></span>";htmlBody+="<a class='btnAttach'></a><a title='点击右键另存为' target='_blank' href='"+obj.fileurl+"'>"+obj.filename+"</a> ("+obj.filesize+")<a href='javascript:deleteFile("+obj.id+");'><img src='styles/dwz/uploadify/cancel.png' height='13' align='middle'/></a>";htmlBody+="</div>";$("#fileList").html(htmlHead+htmlBody+htmlFoot);}//删除文件ajax请求function deleteFile(id){$("#file_"+id).load("Main/post/deletefile/"+id);$("#file_"+id).remove();htmlBody=$("#fileHtmlBody").html();}//close前删除已上传的文件function deleteUploaded(){$(".uploaded").each(function(){var fileid = $(this).val();deleteFile(fileid);});}
------------------------------------------------------------------------
<input id="testFileInput" type="file" name="file" uploader="styles/dwz/uploadify/scripts/uploadify.swf"//必需,uploadify使用的插件cancelImg="styles/dwz/uploadify/cancel.png" script="Main/post/uploadfile"//必需,上传的服务端入口fileQueue="fileQueue" //对应下方的div,用来显示上传进度auto="true" onComplete="onComplete"/> //单个文件上传完成执行的js函数<div id="fileQueue" ></div><div class="divider"></div><div id="fileList" ></div> //此块用于显示已上传完成的文件
------------------------------------------------------
Post.java
public void uploadfile(){String saveDirectory = JFWebConfig.saveDirectory + "download";int maxPostSize = JFWebConfig.maxPostSize;//1024*1024UploadFile file = getFile("file", saveDirectory, maxPostSize);String fileName = file.getFileName();String name=fileName.substring(0,fileName.lastIndexOf('.'));String filetype = fileName.substring(fileName.lastIndexOf('.') + 1);String filesize = FileUtils.getFileSize(file.getFile().length());String fileurl = "upload/" + saveDirectory + "/" + fileName;Tab_Downloadfile df = new Tab_Downloadfile();df.set("filename", name);df.set("fileurl", fileurl);df.set("filesize", filesize);df.set("filetype", filetype);if(df.save()){Tab_Downloadfile lastfile = Tab_Downloadfile.dao.getLastSave();Map<String, Object> map = new HashMap<String, Object>();map.put("id", lastfile.getInt("id"));map.put("filename", lastfile.getStr("filename"));map.put("fileurl", lastfile.getStr("fileurl"));map.put("filesize", lastfile.getStr("filesize"));renderJson(map);}else{renderJson("{\"statusCode\":\"300\",\"message\":\"文件存储出错!\"}");}}
/**删除文件*/public void deletefile(){int id = getParaToInt(0);Tab_Downloadfile df = Tab_Downloadfile.dao.findById(id);if(df!=null){try {File file = new File(PathKit.getWebRootPath() + "/" + df.getStr("fileurl"));if (file.exists()) {file.delete();}df.delete();} catch (Exception e) {e.printStackTrace();}}
0 0
- Jfinal+DWZ使用uploadify插件实现文件上传
- 使用thinkphp实现上传文件(uploadify插件)
- Struts2+ibatis+dwz 框架实现uploadify上传文件
- uploadify插件实现多文件上传
- DWZ中uploadify多文件上传
- DWZ中uploadify多文件上传
- JSP使用文件上传插件uploadify
- uploadify上传文件插件的的使用
- springmvc文件上传使用uploadify插件
- uploadify文件上传插件使用教程
- SSH深度历险(九) Struts2+DWZ+Uploadify实现多文件(文件和图片等等)上传
- Jquery插件(uploadify插件实现多文件上传)
- uploadify实现文件上传
- uploadify插件实现文件多媒体文件上传(spring mvc)
- 使用uploadify上传文件
- 使用uploadify上传文件
- 使用uploadify上传文件
- 使用uploadify上传文件
- Win8操作系统如何进行硬盘分区
- Jquery mobile 新手问题总汇
- Object-C的函数调用机制详解--消息
- dd命令、cp命令详解+dd命令、cp命令对比---delong
- 架构的本质
- Jfinal+DWZ使用uploadify插件实现文件上传
- oracle对大对象类型操作:blob,clob,nclob
- HTTP常用Header讲解
- perl字符串操作符、system函数及其对系统命令的调用
- 写给 Node.js 学徒的 7 个建议
- STM32:GPIO
- Struts2Validator Struts2验证框架
- linux好书
- iOS开发之-Core Location