1

I am trying to read files from my music directory on my PC. I have tried doing it with the node.js file system module, but it is not working. How do I get it to work?😢

3
  • 3
    Vue is a frontend framework. You cant read filesystems with that. The backend should take care of that (like PHP/Node/C#/...). You can make such data available using an API which Vue can call using AJAX requests. Commented Apr 6, 2020 at 12:42
  • I don't have a backend for the app Commented Apr 6, 2020 at 12:54
  • is there no library for this? Commented Apr 6, 2020 at 12:55

2 Answers 2

3

Just a late follow-up. It is possible to read and write files using HTML5 with the FileReader and saveAs(). The browser will open a file dialogue and let the user choose the file, so the user is aware of the file access. It is not possible to read or write to a file without the user's attention.

https://developer.mozilla.org/en-US/docs/Web/API/FileReader

Sign up to request clarification or add additional context in comments.

2 Comments

This page from web.dev is helpful : web.dev/file-system-access/#how-to-use With a demo editor : googlechromelabs.github.io/text-editor
Thank you for posting the link to the FileReader. It took me to the FIleLIst documentation that included the "multiple" input option that now allows me to list and import several local files with one click...HTML5 Rocks!
0

As said by @flame in a comment, it's just impossible, because the browser never have access to the visitor's disk (do you imagine the security issue if it was the case ?).

Vue.js is a Front-end framework, so the application it produces only have access to what the browser has access to.

1 Comment

Ok. I'll just find another approach to the problem. I'll write an API for it then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.