相关疑难解决方法(0)

在JavaScript中不使用FileSystemObject获取文件大小

我正在ASP.NET中的一个项目,我想在其中使用JavaScript获取文件大小.实际上,我得到了解决方案,就像下面这样

<script language="javascript">
    var Fo =new ActiveXObject("Scripting.FileSystemObject");
    var fileName=new String();

    function Trim(input)
    {
        var lre = /^\s*/;
        var rre = /\s*$/;
        input = input.replace(lre, "");
        input = input.replace(rre, "");
        return input;
    }

    function getSize(filePath)
    {
        try
        {
            var thefile = Fo.getFile(filePath);
            var size = thefile.size;
            return size;
        }
        catch(err){}
    }

    function getType(filePath)
    {
        try
        {
            var thefile = Fo.getFile(filePath);
            var fileType = thefile.type;
            return fileType;
        }
        catch(err){}
    }

    function ShowErrorPnl(tblPnl)
    {
        document.getElementById(tblPnl).style.visibility='visible';
        document.getElementById(tblPnl).style.backgroundColor='Yellow';
        document.getElementById(tblPnl).style.borderColor='Silver';
    }

    function UploadFile_CheckType(fileUploadCtrl,messageCtrl,hFieldCtrl,tblPnl)
    {
        try
        { …
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
4467
查看次数

标签 统计

javascript ×1