js实现上传单个文件
2020-11-15 20:25
标签:des http style div code java size javascript c t width js上传文件:js 上传单个文件(任意大小) var xml_http,ado_stream; maxFileLimit=1024*1024*50;//上传文件的大小 SendFile(); ///开始上传文件 js实现上传单个文件,搜素材,soscw.com js实现上传单个文件 标签:des http style div code java size javascript c t width 原文地址:http://www.cnblogs.com/meihao1989/p/3699307.html
疯狂代码 http://www.CrazyCoder.cn/
:http:/www.CrazyCoder.cn/Javascript/Article8329.html
var SendBlockCount,SendCount;
varl
astSendTime,maxFileLimit;
var breaked=false;
var _filename;
var
blockSize=1024*128;
var isUploaded=false;
///处理文件开始上传
function BeginSend()
{
try
{
if(document.getElementById(\"UpFileControl\")&&document.getElementById(\"UpFileControl\").value
.length>0)
{
document.getElementById(\"speed\").innerHTML=\"0KB/Sec\";//进度条
document.getElementById(\"perent\").innerHTML=\"0%\";
document.getElementById(\"perentBar\").style.width=\"0%\";
document.getElementById(\"bar\").style.display=\"block\";
//document.getElementById(\"control\").style.display=\"block\";
document.getElementById(\"divImportData\").style.display=\"block\";
_filename=document.getElementById(\"UpFileControl\").value;
document.getElementById(\"filename\").innerHTML=\"正在上传文件
:\"+_filename.substring(_filename.lastIndexOf(\"\\\\\")+1,_filename.length);
}
elseif(document.getElementById(\"UpFileControl\").value==\"\")
{
alert(\"请先选择要上传的文件\");
window.parent.AllowFunc(); [Page]
document.getElementById(\"btnReset\").disabled=false;
document.getElementById(\"btnUpload\").disabled=false;
document.getElementById(\"UpFileControl\").disabled=false;
Initialize();
return false;
}
else
{
return false;
}
}
catch(ex)
{
alert(\"上传文件过程中出错,原因:\"+ex.description);
//window.parent.AllowFunc();
document.getElementById(\"btnReset\").disabled=false;
document.getElementById(\"btnUpload\").disabled=false;
document.getElementById(\"UpFileControl\").disabled=false;
Initialize();
return false;
}
}
function SendFile()
{
breaked=false;
try
{
ado_stream=newActiveXObject(\"ADODB.Stream\");
ado_stream.Type=1;
ado_stream.Open();
}
catch(ex)
{
window.parent.AllowFunc();
上一篇:js实现无刷新上传