2

I'm aware that JavaScript can't read local files or even files located in repositories without any use of the uploading mechanisms of the Web File API. Now what I want to know is, what is the best simplest alternative to JS. Does jQuery supports the mechanism I need? I need recommendations on what path to take, as I am designing a website builder that needs to read and write files.

P.S. I need the solution to be as JavaScript-based as possible.

7
  • 1
    jQuery does not support anything that the browser API doesn't. Commented Jun 9, 2020 at 18:50
  • Is there a JavaScript framework that supports what I want or do I have to use other programming languages suited for the Web like PHP? Commented Jun 10, 2020 at 1:24
  • It's unclear what you mean by "files located in repositories". And no, another programming language on the server won't help you accessing local files. Commented Jun 10, 2020 at 10:52
  • I meant I need to access the files in my repository in GitHub, not files from the user's local filesystem. Commented Jun 10, 2020 at 12:11
  • Ok, sorry, then it's even more unclear to me what you are doing. What is your actual problem that your program is trying to solve? What does it have to do with javascript and uploading? Where does your javascript program even run? Is the repository you are talking about holding the sources of the program, or is it some other repository? Commented Jun 10, 2020 at 12:30

1 Answer 1

3

You can use the JavaScript FileReader object to read the contents of a file the user selects.

The user will first have to select a file, like if they would want to upload it, and then you can use that information to read the contents of that file.

There are a few nice examples here about how to do that with similar use cases.

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

3 Comments

I know that it's possible to use JavaScript to read files this way. However, this is a major limitation since I want to implement access to all files in my repository, so it can be used for website building.
Oh, that makes it clearer. I googled for javascript git client and found this: github.com/isomorphic-git/isomorphic-git
Thank you. I think this will suffice for now, as I don't have a custom domain yet. But I think I need to find something else in the future if I am to transfer to Bluehost. Thanks, this will allow me to test my editor.

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.