无法从ActiveXObject调用getFile() [英] Unable to call getFile() from ActiveXObject

查看:369
本文介绍了无法从ActiveXObject调用getFile()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我创建了文件上传类的东西,其中我想提供上传文件
大小验证我写了以下代码在chrome和firefox中运行良好。

Hi i created file upload kind of thing, in which i would like to provide the upload file size validation i wrote the following code worked fine in chrome and firefox.

$('#file').change(function() {  
 fileSizeError = (this.files[0].size/(1024*1024) > 1) ? true:false;     
});

但这段代码在IE中不起作用,我想在以下$ b中实现相同的功能$ b fashion

But this code is not working in IE, i would like to implement the same in the following fashion

        var myFSO = new ActiveXObject("Scripting.FileSystemObject");
            var filePath = $('#file')[0].value;
            var theFile = myFSO.getFile(filePath);
            alert('Rajaram');
            var size = theFile.size;
            alert(size + " bytes");

这里myproblem是myFSO.getFile()不工作。警报未提示

Here myproblem is myFSO.getFile() is notworking .the alert is not prompted

推荐答案


这里我的问题是myFSO.getFile()无法正常工作

Here my problem is myFSO.getFile() is not working

感谢天堂!否则,任何浏览网站的人都会非常快地处理很多的麻烦,因为恶意网站会访问他们的文件。

Thank Heaven for that! Otherwise, anyone browsing websites with IE would be in a lot of trouble very quickly, as malicious sites would access their files.

访问Internet区域内容根本不允许通过广泛开放的API(如 FileSystemObject )使用本地文件系统。 (在IE中使用不安全的脚本 ActiveX控件的唯一方法是将页面放在TRUSTED安全区域中,并将该区域的安全性滑块降低到。)

Access to the local file system through a wide-open API like FileSystemObject is simply not allowed for Internet Zone content. (The only way to use an Unsafe for Scripting ActiveX control in IE is to put the page in the TRUSTED security zone and lower that Zone's security slider to Low.)

HTML5文件API 显着更加锁定,只允许JavaScript访问用户选择的有限文件集。

The HTML5 File API is dramatically more locked-down, giving JavaScript restricted access only to the limited set of files the user has selected.

这篇关于无法从ActiveXObject调用getFile()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆