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

15410年前 (2016-06-02)Jfinal5220

页面部分:

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

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

分享给朋友:

相关文章

多说评论框怎么用更好

 1.隐藏屏蔽掉多说评论框的版权链接代码?简单css实现:多说隐藏版权链接,在后台自定义css添加:#ds-thread #ds-reset .ds-powered-by { display...

MyEclipse10.7注册码生成

注意经验里的工具可能不可用,请点击 生成注册码工具  下载。提取码:p1w4MyEclipse10.7注册码激活步骤:点击下面的链接http://jingyan.baidu.com/arti...

jquery 操作html元素(及CSS)

jquery 操作html元素(及CSS)

 $("li").addClass("aui-user-view-cell aui-img") ;  //给元素添加样式$('#a1...

开机密码忘记怎么办

1、重新启动计算机,在启动画面出现后马上按下F8键(不同类型型号电脑启动键不一样,参考附加),选择“带命令行的安全模式”。2、运行过程结束时,系统列出了系统超级用户“administrator”和本地...

MyEclipse 中项目修改SVN的地址

MyEclipse 中项目修改SVN的地址

在工作环境调整时,有的时候SVN服务器的地址需要修改,而正在开发中的项目在Eclipse中有些代码没有提交,此时怎么修改SVN的地址呢?以下有一个简单的办法:一、在MyEclipse中选择Window...

程序员为什么不炫富

程序员为什么不炫富

 提到互联网,尤其是互联网工程师们,人们往往会想到两个词:“高薪”和“高压”。在知乎上“为什么很少见工资高的程序员炫富?”的问题下,一个得票很高的答案是:“乐意炫富的人,不是因为有钱,而是因为付出的少...

发表评论

访客

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