<!DOCTYPE html>
|
<html>
|
<head>
|
<title>文件上载</title>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Pragma" content="no-cache">
|
<meta http-equiv="Cache-Control" content="no-cache">
|
<meta http-equiv="Expires" content="0">
|
<link href="../../../css/home.css" rel="stylesheet"/>
|
<link href="../../../css/common.css" rel="stylesheet" type="text/css">
|
<link href="../../../css/control.css" rel="stylesheet" />
|
|
<script src="../../../js/jquery-1.7.2.min.js"></script>
|
<script src="../../../js/foundation-2.0.js"></script>
|
<script src="../../../js/jquery.form.js"></script>
|
<script src="../../../js/control.js"></script>
|
|
<script type="text/javascript" >
|
var multifile, progress, btn_upload, btn_close, lbl_progress, fileForm, browsertype;
|
var toDB = "", idx = 0;
|
var template = [
|
'<div class="list_line">',
|
'<div id="inform_no" class="inform_no" ></div>',
|
'<div id="content" class="inform_content" ></div>',
|
'</div>'
|
];
|
|
function upload() {
|
var file = multifile.val();
|
if (!file || file.length == 0) {
|
Dialog.alert("请选择上传附件~~");
|
return;
|
}
|
|
if (browsertype.type == "IE" && browsertype.version < 10) {
|
var returnParams = {};
|
fileForm.attr("action", "root/fine/uplodeFile?toDB=" + toDB);
|
fileForm.ajaxForm(function(result){
|
var resultJson = JSON.parse(result);
|
resultJson = $.fm.decode(resultJson);
|
Win.close(resultJson.path);
|
});
|
|
fileForm.submit();
|
return;
|
}
|
|
var files = multifile[0].files;
|
|
doUpload(files);
|
}
|
|
function doUpload(datas){
|
var no = datas.length;
|
Dialog.confirm("信息提示", "确定上载[" + no + "]个附件?", function(result) {
|
if(result){
|
var formData = new FormData();
|
for (var i = 0; i < datas.length; i++) {
|
formData.append("file", datas[i]);
|
}
|
$.ajax({
|
url : "root/fine/uplodeFile?toDB=" + toDB,
|
type : "POST",
|
data : formData,
|
processData : false,
|
contentType : false,
|
success : function(result) {
|
var resultJson = JSON.parse(result);
|
resultJson = $.fm.decode(resultJson);
|
Win.close(resultJson.path);
|
},
|
error : function(result) {
|
alert(JSON.stringify(result));
|
}
|
});
|
}
|
});
|
}
|
|
function refresh(data) {
|
if (data.toDB) {
|
toDB = data.toDB;
|
}
|
}
|
|
function _close() {
|
Win.close();
|
}
|
|
function showFilesName() {
|
var filesname = [];
|
idx = 0;
|
if (browsertype.type == "IE" && browsertype.version < 10) {
|
filesname[0] = multifile.val();
|
}
|
else {
|
var files = multifile[0].files;
|
for (var i = 0; i < files.length; i++) {
|
var fileName = files[i].name.toLowerCase();
|
filesname[i] = fileName;
|
}
|
}
|
|
list_inform.setData(filesname);
|
}
|
|
function renderLine(record, item, sender) {
|
idx++;
|
$("#inform_no", item).html(idx + "、");
|
$("#content", item).html(record);
|
}
|
|
$(document).ready(function() {
|
multifile = $("#multifile");
|
btn_upload = $("#btn_upload");
|
btn_close = $("#btn_close");
|
fileForm = $("#fileForm");
|
browsertype = BrowserType();
|
|
list_inform = new List({
|
template: template,
|
element: "filename",
|
onRender: renderLine
|
});
|
|
$("#fileHover").hover(function(){
|
$("#fileBackground").css("background-color", "#32ad7f");
|
},function(){
|
$("#fileBackground").css("background-color", "#368467");
|
});
|
|
Win.onShow(refresh);
|
});
|
|
</script>
|
</head>
|
|
<body style="overflow: hidden; font: 25px 微软雅黑;">
|
<div style='height: 50px; background-color: #009AD1; color: white; font: 18px 微软雅黑; text-align: left; line-height: 50px; padding-left: 40px'>文件上传</div>
|
<div id="filename" style="border: 1px #CCC dashed; overflow: auto; position: absolute; width: 90%; top: 50px; left: 20px; bottom: 100px;">
|
</div>
|
|
<div style="position: absolute; width:100%; height: 50px; bottom:50px; font-size: 20px; line-height: 50px;">
|
<div style="position: relative; width:100%; height: 100%">
|
<div id="fileHover" class="btn btn-green" style="position: absolute; z-index:100; top: 0px; right: 100px; cursor: pointer; opacity: 0; filter:alpha(opacity=0)">
|
<form id="fileForm" method="post" enctype="multipart/form-data">
|
<input type="file" name="file" id="multifile" multiple="multiple" onchange="showFilesName()" class="btn btn-green"/>
|
</form>
|
</div>
|
<div id="fileBackground" class="btn btn-green" style="position: absolute; z-index:10; top: 0px; right: 100px">选择文件</div>
|
<div style='font-size: 12px; position: absolute; bottom: 0px; right: 150px; height: 20px; line-height: 20px'><label>可多附件上传(IE9+)</label></div>
|
</div>
|
</div>
|
|
<div style='position: absolute; bottom: 10px; left: 40px; right: 40px;'>
|
<div class="btn btn-green" style="float: left;" onclick="upload();">上载</div>
|
<div class="btn btn-green" style="float: right;" onclick="_close();">关闭</div>
|
</div>
|
</body>
|
</html>
|