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

1549年前 (2016-06-02)Jfinal4595

页面部分:

<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")); 
 }

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

分享给朋友:

相关文章

使用Myeclipse 8.5开发基于JAX-WS的Web service实例

使用Myeclipse 8.5开发基于JAX-WS的Web service实例

 本文为Web service 开发入门篇,主要介绍在Myeclipse 8.5环境下开发Web service的服务程序和客户端程序的基本流程。 在Weblogic 11g...

freeMarker 截取字符串(操作字符串函数 )

<#if c.proSummary!?length gt 25>  <!-- 如果长度 >25 截取25个字-->    ...

js/jquery 日历控件及实例下载

js/jquery 日历控件及实例下载

实现日历控件效果:页面:<link href="${base}/resource/${profile.path}/css/lhgcalendar.css" rel="...

iscroll+ ajax+ Jfinal 实现手机下拉加载更多

  <script src="${base}/resource/front/js/iscroll.js"></script>一、页面<div...

是谁动了我的座位

是谁动了我的座位

女孩一上火车,见自己的座位上坐着一男士。她核对自己的票,客气地说:“先生,您坐错位置了吧?” 男士拿出票嚷嚷着:“看清楚点,这是我的座,你瞎了?” 女孩仔细看了他的票,不再做声,默...

目标管理法——目标分解法

让自己的人生更幸福更有意义关键是:要将梦想转化为具体的目标,然后合理的分解,达到量化,指标化!现将学习到的两种非常有效的目标分解法分享给所有梦想、有激情的朋友:祝愿大家都能梦想成真! 一、俄...

发表评论

访客

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