dwz +jfinal 批量多文件上传 实例

1549年前 (2016-06-02)Jfinal4775

页面部分:

<link href="${root}/style/dwz/uploadify/css/uploadify.css" rel="stylesheet"    type="text/css" media="screen" /><script src="${root}/style/dwz/uploadify/scripts/jquery.uploadify.min.js"    type="text/javascript"></script><style type="text/css" media="screen">
.my-uploadify-button {
    background:none;
    border: none;
    text-shadow: none;
    border-radius:0;
}
.uploadify:hover .my-uploadify-button {
    background:none;
    border: none;
}
.fileQueue {
    width: 400px;
    height: 150px;
    overflow: auto;
    border: 1px solid #E5E5E5;
    margin-bottom: 10px;
}
</style>
<div class="pageContent" style="margin: 0 10px" layoutH="50">
    <div class="divider"></div>
    <input id="testFileInput2" type="file" name="model.information" 
        uploaderOption="{
            swf:'${root}/style/dwz/uploadify/scripts/uploadify.swf',
            uploader:'${root!}/admin/itemInfo/saveFile/${itemid}',
            formData:{PHPSESSID:'', ajax:1},
            queueID:'fileQueue',
            buttonImage:'${root}/style/dwz/uploadify/img/add.jpg',
            buttonClass:'my-uploadify-button',
            width:102,
            auto:false,
            onUploadSuccess:uploadifySuccess
        }"
    />
    <div id="fileQueue" class="fileQueue"></div>
    <input type="image" src="${root}/style/dwz/uploadify/img/upload.jpg" onclick="$('#testFileInput2').uploadify('upload', '*');"/>
    <input type="image" src="${root}/style/dwz/uploadify/img/cancel.jpg" onclick="$('#testFileInput2').uploadify('cancel', '*');"/>
    <br/><br><br><br> 
    <div id="shownode" ></div>    
</div>

<script type="text/javascript">
function uploadifySuccess(file, data, response){
      // alert('文件[' + file.name + ']上传成功了,' + response + '返回值:' + data);  
       $("#shownode").append("<p ><font style='font-size: 15px'>已成功上传["+file.name+"]文件</font></p>");  
}
</script>

后台部分:(即使是多文件上传,jfinal后台多文件获取文件 也是一个一个的获取)

public void saveFile(){       
          UploadFile uploadFile = getFile("model.information", "file/");    
          String time = new SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date());   
          File file = uploadFile.getFile();        
          String ss=uploadFile.getFileName();      
           file.renameTo(new File(PathKit.getWebRootPath()+ "/upload/file/" + time +"."+ ss.split("\\.")[1]));  //文件重命名    
            ItemFile itemFile=getModel(ItemFile.class,"itemFile");     
           itemFile.setItemid(getParaToInt());//项目ID     
           itemFile.setUrl(time +uploadFile.getFileName());  
           itemFile.save();       
           render(DwzRender.closeCurrentAndRefresh("上传成功","./admin/itemInfo")); 
 }

本文原创,转载必追究版权。

分享给朋友:

相关文章

 程序员的中秋礼物.......

程序员的中秋礼物.......

【小姐你好,我是程序员】“小姐你好,我是程序员。”女生礼貌地回答:“你好,程先生。”男:“……哦,叫我序员就可以了。”   【程序员的愿望】有一天一个程序员见到了上帝。上...

org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locked dir

 svn更新或提交时候报错:org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locke...

如何彻底卸载删除oracle数据库

 windows下如何彻底删除Oracle 软件环境: 1、Windows 2000+ORACLE 8.1.7 ,oracle 10g2、ORACLE安装路径为:C:\ORACLE实现方...

get方式调用http接口   Header赋参数值

get方式调用http接口 Header赋参数值

   /**      195.     * 发送...

freeMarker Jfinal 获取session里的值

问题:freeMaker session取值的常用格式都试过 session["xxx"],session.xxx 直接xxx 都取不出来?????解决:JFinal与Struts...

org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: Working cop

org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: Working cop

SVN更新出现问题:org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: W...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。