Convert URL to File or Blob for FileReader.readAsDataURL

后端 未结 8 892
情话喂你
情话喂你 2020-11-27 13:57

Reference: FileReader.readAsDataURL

Considering the following example:

function previewFile(file) {

  var reader  = new FileReader();

  reader.onlo         


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 14:49

    This information is outdated as of now, but cannot be deleted.

    1. You can create File instances just by specifying a path when your code is chrome-privileged:

      new File("/path/to/file");
      

      File is a sub-class of Blob, so all File instances are also valid Blobs. Please note that this requires a platform path, and not a file URL.

    2. Yes, FileReader is available to addons.

    File and FileReader are available in all windows. If you want to use them in a non-window scope (like bootstrap.js or a code module), you may use nsIDOMFile/nsIDOMFileReader.

提交回复
热议问题