HarmonyOS ArkTS是否存在浏览器端的FileReader帮助读取文件?

如题:HarmonyOS ArkTS是否存在浏览器端的FileReader帮助读取文件?

阅读 423
1 个回答

请参考:

Web({ src: $rawfile('TestonShowFileSelector.html'), controller: this.controller })
  .javaScriptAccess(true)
  .domStorageAccess(true)
  .onShowFileSelector((event) => {
    //调用文件管理器
    console.log('MyFileUploader onShowFileSelector invoked')
    const documentSelectOptions = new picker.DocumentSelectOptions();
    // 选择媒体文件的最大数目
    documentSelectOptions.maxSelectNumber = 2;
    const documentViewPicker = new picker.DocumentViewPicker();
    documentViewPicker.select(documentSelectOptions).then((DocumentSelectResult: Array<string>) => {
      this.uris = DocumentSelectResult;
      console.info('photoViewPicker.select to file succeed and uris are:' + this.uris);
    }).catch((err: BusinessError) => {
      console.error(`Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
    })
    return false 
})

h5:

<body>
<form id="upload-form" enctype="multipart/form-data">
    <!-- 修改type属性为camera -->
    <input type="file" id="upload" name="upload" accept="image/*" capture="camera" />
    <!-- 添加一个图片元素用于展示图片 -->
    <img id="preview"/>
</form
</body>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏