zoukankan      html  css  js  c++  java
  • js实现上传单个文件

    js上传文件:js 上传单个文件(任意大小)
    疯狂代码 http://www.CrazyCoder.cn/ :http:/www.CrazyCoder.cn/Javascript/Article8329.html

    var xml_http,ado_stream;
    var SendBlockCount,SendCount;
    varl astSendTime,maxFileLimit;
    var breaked=false;
    var _filename;
    var blockSize=1024*128;
    var isUploaded=false;

    maxFileLimit=1024*1024*50;//上传文件的大小


    ///处理文件开始上传
    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);

    SendFile();
    }
    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();

  • 相关阅读:
    mybatis 查询一对多子表只能查出一条数据
    Docker 查看容器里Log4写的日 志文 件里的日志
    MYSQL之union的使用
    【前端开发】常见好用的流程图框架
    【推荐】好网站推荐
    【前端工具】好用的数据库工具Navicat
    jQuery ajax
    thinkphp6.0封装数据库及缓存模型
    Unity 3D使用C#脚本实例
    Unity 3D简单使用C#脚本,脚本的执行顺序
  • 原文地址:https://www.cnblogs.com/meihao1989/p/3699307.html
Copyright © 2011-2022 走看看