2

Basically what im looking for is a way for the user to upload an html file when they click <input type="file"/> button.

When the user selects an HTML file, I want to take the HTML code and place it within a div. Can this be done without server-side languages?

1 Answer 1

2

Using javascript You cannot browse on a clients disk files. However your case is possible. Please check the below stackover question which exactly matches your requirement. Refer Paolo Moretti answer. Here is the link: How to open a local disk file with Javascript?

As you want to browse/upload only HTML files add "accept" to your input file type like this:

<input type="file" accept="text/html"/>

In HTML5 you can use file extensions as the accept like this:

<input type="file" accept=".html"/>
Sign up to request clarification or add additional context in comments.

Comments

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.