日期:2014-05-17 浏览次数:20396 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>仿网易126网络硬盘上传 by littlelam</title> </head> <script> //css样式以及部分代码源自126 var TotalFiles = 0; function AddFiles() { TotalFiles ++; var file=document.createElement("input"); file.type = "file"; file.id = "f"+ TotalFiles.toString(); file.name = "files"+ TotalFiles.toString(); file.hideFocus = true; file.size = 1; file.style.cssText = "cursor:pointer; width:1px; border:none; height:32px; padding:0px; margin:0px;position:absolute; opacity:0;filter:alpha(opacity=0);left:-32px !important;left:-5px;left/**/:-3px; font-size:20px;"; file.onchange = function () { for (var i=1;i<=TotalFiles;i++) { if ($("f"+i.toString())&&$("f"+i.toString())!=this) { if ($("f"+i.toString()).value == this.value) { DelFile(this.id.replace("f","")); AddFiles(); window.alert("已有相同文件,无须重复上传"); return; } } } $("s"+TotalFiles.toString()).innerHTML = "<table class=oplist_filelist cellSpacing=0 cellPadding=0 width="100%" border=0><tr class=tr_file><td class=td_pathlist> " + $("f"+TotalFiles.toString()).value + "</td><td class=td_operate noWrap><span onclick="DelFile('"+TotalFiles.toString()+"')" style="cursor:pointer;color:red;font-weight:bloder;">X 移除</span></td></tr></table>"; this.style.display = "none"; AddFiles(); CheckUploadDiv(); }; $("uploadInput").appendChild(file); var div=document.createElement("div"); div.id = "s"+ TotalFiles.toString(); $("uploadDiv").appendChild(div); } function DelFile(str) { $("uploadInput").removeChild($("f"+str)); $("uploadDiv").removeChild($("s"+str)); CheckUploadDiv(); } function CheckUploadDiv() { $("divNone").style.display = $("uploadDiv").innerHTML.indexOf("移除")==-1?"":"none"; } function DelEmpty() { for (var i=1;i<=TotalFiles;i++) { if ($("f"+i.toString())) { if ($("f"+i.toString()).value == "") $("uploadInput").removeChild($("f"+i.toString())); } } } function checkForm() { var HaveFile = false; for (var i=1;i<=TotalFiles;i++) { if ($("f"+i.toString())) { if ($("f"+i.toString()).value != "") { HaveFile = true; break; } } } if (!HaveFile) { window.alert("点击“添加文件”按钮 添加要上传的文件"); return false; } $("submitButton").disabled = true; DelEmpty(); return true; } function $(id) { return document.getElementById(id); } </script> <style> a.btn{background-image:url(http://mimg.163.com/netfolder/images/all_toolbar.gif);display:block; background-position:2px -32px; margin:6px 4px;float:left; border:1px so