OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

JavasScript Open Local File

  • Thread starter Thread starter Ed Ipser
  • Start date Start date
E

Ed Ipser

Guest
I am writing a Figma plugin that uses JavaScript and I need to open a file from the plugin folder. This is not JS on a webpage. I mention that because all the JS examples I can find assume a <input type='file'/>.

The code should look something like this:

Code:
function readFile (file: File)
{
    let reader = new FileReader() ;
    reader.onload = () =>
    {
        console.log(reader.result) ;
    }
    reader.readAsText(file) ;
}

readFile(new File("folder/File.xml")) ;

<p>I am writing a Figma plugin that uses JavaScript and I need to open a file from the plugin folder. This is not JS on a webpage. I mention that because all the JS examples I can find assume a <code><input type='file'/></code>.</p>
<p>The code should look something like this:</p>
<pre><code>function readFile (file: File)
{
let reader = new FileReader() ;
reader.onload = () =>
{
console.log(reader.result) ;
}
reader.readAsText(file) ;
}

readFile(new File("folder/File.xml")) ;
</code></pre>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top