本 站 搜 索 |
文 章 阅 读 排 行 |
|
文 章 信 息 |
 |
无组件多个文件上传客户端 |
|
|
〖文章分类:电脑·手机·网络 / 网站设计·开发·优化〗〖阅读选项〗 |
|
现在功能放在一个htm网页中,先选择条件,再在要上传的文件夹中选择一个文件,然后程序会列出所有符合条件的文件.使用之前,就改进form的action.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="haokucn.com">
<meta name="Author" content="haiwa">
<title>Upload many file - haokucn.com</title>
<style>
*{font:menu}
input{font-size:12px;}
.checkbox{}
.showdiv{padding-left:40px;}
</style>
</head>
<body>
请选择要上传的条件的过滤条件:<br>
<input onclick="document.all.strdiv.style.display=(this.checked?’’:’none’)" type="checkbox" class="checkbox" name="checkstr" id="checkstr" value="1"> <label for="checkstr">文件名</label><br>
<div class="showdiv" id="strdiv" style="display:none;"><select name="filestrconditions" xonchange="alert(this.options[this.selectedIndex].value)">
<option value="1">包含</option>
<option value="0">不包含</option>
</select>
<input type="text" size="8" name="filestrstr" value=""> <input type="checkbox" class="checkbox" name="checkstrinstart" id="checkstrinstart" value="1"> <label for="checkstrinstart">文件名开头</label>
<br><input type="checkbox" class="checkbox" name="checkstrcase" id="checkstrcase" value="1"> <label for="checkstrcase">区分大小写</label>
<!-- <br><input type="checkbox" class="checkbox" name="checkreg" id="checkreg" value="1"> <label for="checkreg">使用正则表达式</label>
--></div>
<div><input onclick="document.all.sizediv.style.display=(this.checked?’’:’none’)" type="checkbox" class="checkbox" name="checksize" id="checksize" value="1"> <label for="checksize">大小</label></div>
<div class="showdiv" id="sizediv" style="display:none;"><select name="filesizeconditions" xonchange="alert(this.options[this.selectedIndex].value)">
<option value="1">至多</option>
<option value="0">至少</option>
</select>
<input type="text" size="8" id="filesizelimit" value="100" style="text-align:right"> K
</div>
<div><input onclick="document.all.typediv.style.display=(this.checked?’’:’none’)" type="checkbox" class="checkbox" name="checktype" id="checktype" value="1"> <label for="checktype">类型</label></div>
<div class="showdiv" id="typediv" style="display:none;"><select name="fileextconditions" xonchange="alert(this.options[this.selectedIndex].value)">
<option value="1">选择所选类型</option>
<option value="0">排除所选类型</option>
</select><br>
<SCRIPT LANGUAGE="JavaScript">
<!--
allextstr = "gif,bmp,jpg,png<br>,js,css,html,htm,asp,aspx,java<br>,mp3,avi,rm,ram,mid,wmv<br>,doc,xls,ppt,eml,txt,pdf,chm<br>,rar,zip,exe,reg"
extarr = allextstr.split(",")
for (var l = 0;l<extarr.length;l++)
{
document.write(’<label for="ft’+l+’"><input onclick="selectfiletype()" type="checkbox" class="checkbox" name="ft" id="ft’+l+’" value="’+extarr[l]+’">.’+extarr[l]+’</label>’)
}
//-->
</SCRIPT>
<input type="hidden" name="allselectfileeext">
</div>
<div><input onclick="document.all.datediv.style.display=(this.checked?’’:’none’)" type="checkbox" class="checkbox" name="checkdate" id="checkdate" value="1"> <label for="checkdate">日期</label></div>
<div class="showdiv" id="datediv" style="display:none;">
<input checked onclick="document.all.filedate.disabled=!this.checked" type="radio" class="checkbox" name="sdate" id="sdate0" value="0"> <label for="sdate0">前</label> <input type="text" size="8" name="filedate" value="1" style="text-align:right"> 小时(可以使用1*24)<br>
<span style="width:60px;"><input onclick="document.all.filedate.disabled=this.checked" type="radio" class="checkbox" name="sdate" id="sdate1" value="1"> <label for="sdate1">介于</label></span> <object disabled id=startdate height="22" width="100" classid="clsid:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1" name="date1">
<param name="CurrentDate" value=Date(now())>
</object><br>
<span style="width:60px;"> 和 </span><object disabled id=enddate height="22" width="100" classid="clsid:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1" name="date2">
<param name="CurrentDate" value=Date(now())>
</object>
</div>
在要上传的文件夹中选择一个文件:<input type="file" name="spath" size="1" onchange="filelist()"> ,然后在弹出的安全提示对话框中选择<B>是</B><br>
<input type="hidden" name="pathstr">
<input type="hidden" name="fileliststr">
<form name="form1" method="post" action="upfiles.asp?up=1" enctype="multipart/form-data">
<input type="hidden" name="act" value="upload">
<div id=MyZone></div>
<SCRIPT LANGUAGE="VBScript">
<!--
’http://www.51windows.Net
’海娃@2004-11-5
function checkfilename(fname1)
fname = fname1
check = true
searchstr = document.all.filestrstr.value
if (document.all.checkstr.checked) and len(searchstr)>0 then
if (document.all.checkstrcase.checked=false) then
fname = lcase(fname)
searchstr = lcase(searchstr)
end if
if (document.all.checkstrinstart.checked) and (len(fname) >= len(searchstr)) then
fname = left(fname,len(searchstr))
end if
if (document.all.filestrconditions.value="1") then
if instr(fname,searchstr)>0 then
check = true
else
check = false
end if
else
if instr(fname,searchstr)>0 then
check = false
else
check = true
end if
end if
end if
if HasCnStr(fname1) then
check = false
end if
checkfilename = check
end function
function checkextname(fname1)
fname = fname1
check = true
if (document.all.checktype.checked) then
fnameext = lcase(fname)
while instr(fnameext,".")>0
fnameext = right(fnameext,len(fnameext)-1)
wend
if (document.all.fileextconditions.value="1") then
if instr(document.all.allselectfileeext.value,","& fnameext &",")>0 then
check1 = true
else
check = false
end if
else
if instr(document.all.allselectfileeext.value,","& fnameext &",")>0 then
check = false
else
check = true
end if
end if
end if
checkextname = check
end function
function checksize(fsize1)
nfilesizelimit = document.all.filesizelimit.value
if isnumeric(nfilesizelimit) = false then
checksize = true
exit function
end if
fsize = fsize1
nfilesizelimit = nfilesizelimit*1024
check = true
if (document.all.checksize.checked) then
if (document.all.filesizeconditions.value="1") then
if fsize>nfilesizelimit then
check = false
else
check = true
end if
else
if fsize<nfilesizelimit then
check = false
else
check = true
end if
end if
end if
checksize = check
end function
function checkdate(fdate1)
fdate = fdate1
check = true
if (document.all.checkdate.checked) then
if (document.all.sdate0.checked) then
nfiledate = eval(document.all.filedate.value)
if isnumeric(nfiledate) = false then
checkdate = true
exit function
end if
if fdate>dateadd("h",-nfiledate,now) then
check = true
else
check = false
end if
else
if (fdate > startdate.value and fdate<enddate.value) or (fdate < startdate.value and fdate > enddate.value) then
check = true
else
check = false
end if
end if
end if
checkdate = check
end function
Function HasCnStr(str)
Set regEx=New RegExp
regEx.Pattern="[\u4E00-\u9FA5]"
regEx.IgnoreCase=true
regEx.Global=True
HasCnStr = regEx.test(str)
End Function
function formatsendkey(str)
str1 = str
str1 = replace(str1,"%","{%}")
str1 = replace(str1,"~","{~}")
str1 = replace(str1,"^","{^}")
str1 = replace(str1,"+","{+}")
formatsendkey = str1
end function
function filelist()
Set fsoBrowse = CreateObject("Scripting.FileSystemObject")
cpath = document.all.spath.value
if instr(cpath,":")>0 then
if HasCnStr(cpath) then
msgbox "对不起,暂时不支持中文路径,请把要上传的文件移动或复制到一个非中文路径下的文件夹中。"
exit function
end if
while right(cpath,1)<>"\"
cpath = left(cpath,len(cpath)-1)
wend
dim allfilename,filesize,filenum
allfilename = ""
filesize = 0
filenum = 0
if fsoBrowse.FolderExists(cpath)then
Set theFolder=fsoBrowse.GetFolder(cpath)
Set theFiles=theFolder.Files
For Each x In theFiles
if checkfilename(x.name) and checkextname(x.name) and checksize(x.Size) and checkdate(x.DateLastModified) then
filesize = filesize + x.Size
filenum = filenum + 1
’msgbox checkextname(x.name)
’msgbox (x.DateLastModified)’DateCreated
allfilename = allfilename & formatsendkey(x.name) & "*"& formatnumber(x.Size/1024,2) &"|"
end if
next
end if
set fsoBrowse = nothing
if len(allfilename)>0 then allfilename = left(allfilename,len(allfilename)-1)
document.all.pathstr.value = cpath
document.all.fileliststr.value = allfilename
if len(allfilename) > 0 then
Bstart = msgbox("共"& filenum &"个文件,"& formatnumber(filesize/1024/1024,3) &"M"&vbnewline & vbnewline&"开始列出文件吗?",vbYesNo)
if Bstart = 6 then
creatinput()
end if
else
msgbox "没有查找到适合的文件"
end if
else
msgbox "路径错误"
end if
end function
//-->
</SCRIPT>
<script language="JavaScript">
//http://www.51windows.Net
//海娃@2004-11-5
var allfilefolder
var allfilename
var filearr
var start = 1
var end
var s;
function selectfiletype()
{
var sHTML = ’,’;
var oListft = document.all.ft;
for ( var i = 0 ; i < oListft.length ; i++ )
{
var sValue = oListft[i].value.replace("<br>","");
if (oListft[i].checked)
{
sHTML += sValue+"," ;
}
}
document.all.allselectfileeext.value = sHTML;
}
function creatinput()
{
var allfilefolder = document.all.pathstr.value
var allfilename = document.all.fileliststr.value
var filearr = allfilename.split("|")
end = filearr.length+1
formhtml = ""
for (i=start;i<end;i++)
{
k = "00000"+i;
k = k.substr(k.length-4,4)
formhtml+="("+k+").<input type=’file’ style=’ime-mode:disabled;’ size=’80’ name=’file"+i+"’><span style=’width:60px;text-align:right;’> "+filearr[i-1].split("*")[1]+"k</span><br>"
}
document.all.MyZone.innerHTML=formhtml;
s = setInterval("setfile(start)",50);
}
function setfile(j)
{
var allfilefolder = document.all.pathstr.value
var allfilename = document.all.fileliststr.value
var filearr = allfilename.split("|")
eval("document.all.file"+j).focus();
var WshShell=new ActiveXObject("WScript.Shell")
WshShell.sendKeys(allfilefolder+filearr[j-1].split("*")[0])
start++
if (start==end){clearInterval(s);start=1;}
}
</script>
上传到:<input name="filepath" type="text" value="/xxx/" size="40">
<input type="submit" name="Submit" value="上传文件"></form>
</body>
</html>
|
文章作者:未知 更新日期:2006-05-13 |
〖文章浏览:〗〖打印文章〗〖发送文章〗 |
|
|
|
|
·本站大部分文章转载于网络,如有侵权请留言告知,本站即做删除处理。
·本站法律法规类文章转载自[中国政府网(www.org.cn)],相关法律法规如有修订,请浏览[中国政府网]网站。
·本站转载的文章,不为其有效性,实效性,安全性,可用性等做保证。
·如果有什么问题,或者意见建议,请联系[网站管理员]。 |
|