This section JS is the directory upload Oh, is equivalent to bulk upload files.
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> test File Upload </title>
<script type= "text/web Effects" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script >
<script language= "javascript" type= "Text/javascript" >
$ (function () {
Showfolderfilelist ("D:codenetwebimagesshoptemplets");
});
function Showfolderfilelist (filepath) {
var fso, F, FC, SF;
FSO = new ActiveXObject ("Scripting.FileSystemObject");
try{
F = fso.getfolder (filepath);
}catch (Err) {
Alert ("File path error or no!!");
return false;
}
List all Files
FC = new Enumerator (f.files);
var filename = "";
for (;! Fc.atend (); Fc.movenext ()) {
Filename=fc.item (). Name;
$ (' <div filepath= ' + filepath + filename + ' "uploadstate=" Wait "> ' + filepath + filename + ' </div> '). Appendto (' #showarea ');
}
Loop recursively read folder files
SF = new Enumerator (f.subfolders);
var foldername = "";
for (;! Sf.atend (); Sf.movenext ()) {
FolderName = Sf.item (). Name;
Showfolderfilelist (filepath + foldername + "/");
}
}
function Startupload () {
var s = $ (' #uploaddir '). Val (). replace (//gi, '/');
if (s.substring (s.length-1, s.length)!= '/') {
s + = '/'
}
Showfolderfilelist (s)
UploadFile ();
}
Upload
function UploadFile () {
if ($ (' #showarea div[uploadstate=wait] '). Length > 0) {
var Thisnode = $ (' #showarea div[uploadstate=wait] '). EQ (0)
var wshshell=new activexobject ("Wscript.Shell");
$ (' #fileupload '). focus ();
Wshshell.sendkeys ($ (thisnode). attr (' filepath ')); There is no Chinese in the path
Uploadform.submit ();
$ (' #fileupload '). focus ();
$ (' #fileupload '). Get (0). createTextRange (). Select ();
Wshshell.sendkeys (' {del} ');
var dotstr = '. ';
$ (' <span></span> '). Appendto (thisnode). CSS tutorial (' Color ', ' green ');
var uploadstate = setinterval (function () {
if ($ (thisnode). attr (' uploadstate ') = = ' OK ') {
Clearinterval (uploadstate);
$ (Thisnode). Find (' span '). CSS (' Color ', ' red '). Text (' (completed) ');
UploadFile ();
}else{
if (Dotstr.length >) {dotstr = '. ';} else{dotstr + = '. ';}
$ (Thisnode). Find (' span '). Text (' (uploaded in ' + Dotstr + ') ');
}
}, 1000);
}
}
Call this function in the return page of the IFRAME to implement the loop upload, otherwise the dead loop
function Uploadfinish () {
$ (' #showarea div[uploadstate=wait] '). EQ (0). attr (' uploadstate ', ' OK ');
}
</script>
<style type= "Text/css" >
body,td,th {
font-family: "Microsoft Ya Hei", Tahoma, Helvetica, Arial, 5b8b4f53, Sans-serif;
}
</style>
<body>
<form action= "/a.html" method= "post" name= "LoginForm" style= "margin:0" 0; padding:0 0; " >
<input name= "Uploaddir" id= "Uploaddir" type= "text" value= "d:a" style=; "width:800px"
<input type= "button" value= "Start" id= "Startit" name= "Startit" onclick= "Javascript:startupload" (); " />
</form>
<form action= "/index/upload" method= "post" name= "Uploadform" enctype= "Multipart/form-data" target= "Hidden_frame" >
<input type= "File" Name= "FileUpload" id= "FileUpload"/>
<iframe name= ' hidden_frame ' id= ' hidden_frame ' style= ' Display:none ' ></iframe>
</form>
</iframe>
<div id= "Showarea" >
</div>
</body>