简体   繁体   English

从本地文件获取File对象

[英]get File object from local file

From html page, I select a "file index" text file in a local folder (element input type="file").This file list several file names located in the same current folder. 从html页面,我在本地文件夹中选择一个“文件索引”文本文件(元素输入类型=“ file”)。此文件列出了位于同一当前文件夹中的几个文件名。 How, in javascript, can I get a File descriptor from these other files from their file names ? 如何在JavaScript中从这些其他文件的文件名中获取文件描述符? I try with following code, but I don't know what to do after: 我尝试使用以下代码,但是之后我不知道该怎么办:

function GetFileHandleFromUrl(localURL) {
var http = new XMLHttpRequest();
http.open('GET', localUrl, false);
http.send(null); // success, return file content

var myFile = ???;
return myFile;

How...can I get a File descriptor from these other files from their file names ? 如何...如何从其他文件的文件名中获取文件描述符?

You can't. 你不能 You can read the file and get the names from it using the File API (I demonstrate it in this other answer ), but you can't then get File instances for those other files in any standard way. 您可以使用File API读取文件并从中获取名称(我在另一个答案中进行了演示),但是您随后无法以任何标准方式获取这些其他文件的File实例。 The File API only grants you access to files the user has explicitly chosen to give you access to, via an input type=file . File API仅通过input type=file授予您访问用户明确选择授予您访问权限的文件的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM