相关疑难解决方法(0)

HTML5 FIle API:读取文件时出现安全性错误

问题解决了,看了评论

我在HTML5文件API中遇到的第三个问题:我仍在Mac OS X Snow Leopard上使用Chrome 12,我仍在尝试使用HTML5文件API读取文件,但因为"SECURITY_ERR"而调用了FileHandler.error() occurres.我尝试读取的文件是来自桌面的常规.txt文件,但它既不能用于其他文件,尽管我可以使用常规应用程序打开它们.

function FileHandler(files, action) {
    console.log('FileHandler called.');

    this.files = files;
    this.reader = new FileReader();
    this.action = action;

    this.handle = function() {
        console.log('FileHandler.handle called.');

        for (var i = 0; i < this.files.length; i++) {
            this.reader.readAsDataURL(files[i]);
        }
    }

    this.upload = function() {
        console.log('FileHandler.upload called.');
        console.log(this.reader);

        data = {
            content: this.reader.result
        }

        console.log(data);
    }

    this.error = function() {
        console.log('An error occurred while reading the file.');
        console.log(this.reader.error);
    }

    this.reader.onload = this.upload.bind(this);
    this.reader.onerror = this.error.bind(this);
}
Run Code Online (Sandbox Code Playgroud)

该代码生成以下控制台输出:http …

javascript html5 filereader fileapi

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

如何让文件被选中

我正在使用旧版本构建一个颤振网络。我有一个 FileUploadInputElement。我需要从该元素中选择文件。

@override
  Widget build(BuildContext context) {
    FileUploadInputElement fileUploadInputElement = FileUploadInputElement();
    ui.platformViewRegistry.registerViewFactory(
        'animation-Image-html', (int viewId) => fileUploadInputElement);



    return SizedBox(
      child: HtmlElementView(
        viewType: 'animation-Image-html',
      ),
    );
}
Run Code Online (Sandbox Code Playgroud)

flutter-web

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

标签 统计

fileapi ×1

filereader ×1

flutter-web ×1

html5 ×1

javascript ×1