<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Test file upload</title>
<script type="text/javascript" src="/ajax/libs/jquery/1.4.2/"></script>
<script language="javascript" type="text/javascript">
$(function(){
//ShowFolderFileList("D:\\CodeNet\\web\\Images\\shopTemplets");
});
function ShowFolderFileList(FilePath){
var fso, f, fc, sf;
fso = new ActiveXObject("");
try{
f = (FilePath);
}catch(err){
alert("File path error or does not exist!!");
return false;
}
// List all files
fc = new Enumerator();
var fileName = "";
for(;!();()){
fileName=().Name;
$('<div filePath="' + FilePath + fileName + '" uploadState="wait">' + FilePath + fileName + '</div>').appendTo('#showArea');
}
// Loop recursively read folder files
sf = new Enumerator();
var folderName = "";
for(;!();()){
folderName = ().Name;
ShowFolderFileList(FilePath + folderName + "/");
}
}
function startUpload(){
var s = $('#uploaddir').val().replace( /\\/gi, '/' ) ;
if(( - 1 , ) != '/'){
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("");
$('#fileupload').focus();
($(thisNode).attr('filePath')); // No Chinese in the path
();
$('#fileupload').focus();
$('#fileupload').get(0).createTextRange().select();
('{del}');
var dotStr = '.';
$('<span></span>').appendTo(thisNode).css('color', 'green');
var uploadState = setInterval(function(){
if($(thisNode).attr('uploadState') == 'ok'){
clearInterval(uploadState);
$(thisNode).find('span').css('color', 'red').text('(complete)');
uploadFile();
}else{
if( > 15){ dotStr = '.'; }else{ dotStr += '.'; }
$(thisNode).find('span').text('(upload' + dotStr + ')');
}
}, 1000);
}
}
// Call this function in the return page of the iframe to realize loop upload, otherwise it will be a dead loop
function uploadFinish(){
$('#showArea div[uploadState=wait]').eq(0).attr('uploadState', 'ok');
}
</script>
<style type="text/css">
body,td,th {
font-family: "Microsoft Yahei", Tahoma, Helvetica, Arial, \5b8b\4f53, sans-serif;
}
</style>
</head>
<body>
<form action="/" method="post" name="loginForm" style="margin:0 0; padding:0 0;">
<input name="uploaddir" type="text" value="D:\a" style="width:800px;" />
<input type="button" value="start" 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" />
<iframe name='hidden_frame' style='display:none'></iframe>
</form>
</iframe>
<div >
</div>
</body>
</html>