Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:28:18+00:00 2026-06-06T19:28:18+00:00

How could you use HTML to open a file on the client’s machine as

  • 0

How could you use HTML to open a file on the client’s machine as plaintext (i.e., a .cpp, .txt, or even a .html file)? I want to extract the plain textfile from the user’s machine into an HTML <textarea>. Just FYI, I am using hiccup, clojure, and webnoir to generate the HTML and server so those are all other options to use to help the process along.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:28:19+00:00Added an answer on June 6, 2026 at 7:28 pm

    You have two main options: upload the file to your server to be served as HTML content or use HTML 5’s File API. This question also addresses a few more options (like applets, enabling drag-and-drop with the File API, etc.)


    Upload the file

    1. Have the users choose the file using an <input type="file" .../> on one page
    2. Upload the file contents to your server.
    3. Redirect to a different page to show the file contents
    4. Serve the uploaded file’s contents in a textarea on that page.

    Pros:

    • This method is pretty simple and straightforward.
    • You can scan the file and do some heavy processing on the server

    Cons:

    • Trips to the server can be time consuming.

    HTML 5 Solution

    1. Have the user choose the file using an <input type="file" .../>
    2. Instead of posting the contents, use JavaScript to load the file into your HTML 5 local storage (see code below)
    3. Use JavaScript to insert the contents of the file into your DOM.

    Pros:

    • No trip to the server (faster)

    Cons:

    • Any and all validation/processing must be done on the client side in JavaScript. This makes your client heavier and allows users to see/modify your code (which you might not need to care about).

    I grabbed this code snippet from this site, which has some good examples of using the File API:

    function onInitFs(fs) {
    
      fs.root.getFile('log.txt', {}, function(fileEntry) {
    
        // Get a File object representing the file,
        // then use FileReader to read its contents.
        fileEntry.file(function(file) {
           var reader = new FileReader();
    
           reader.onloadend = function(e) {
               // Do something with the contents, which are stored in 'this.result'
           };
    
           reader.readAsText(file);
        }, errorHandler);
    
      }, errorHandler);
    
    }
    
    window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a novice designer who could just use HTML to design my own
I could use another pair of eyes. This script does what I want in
I want to open a file in a popup window. The file must be
http://docs.oracle.com/javase/1.5.0/docs/guide/jpda/trace.html Could anyone please provide me couple of examples of how to use Java
I could use another set of eyes - perhaps I am missing somehting obvious.
I could use some help with expression conversion. I have a method on a
I could use a bit of help with this, as i am new to
could someone help me with the regex pattern that i could use to match
It seems like you could use a mashup of Relector and a Debugger to
I know I could use PHP to do this, but wanted to find out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.