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 8923389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:06:17+00:00 2026-06-15T07:06:17+00:00

What techniques are used to load a file (ASCII or Binary) into a variable

  • 0

What techniques are used to load a file (ASCII or Binary) into a variable (var file = “text”;) in JavaScript?

  • 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-15T07:06:18+00:00Added an answer on June 15, 2026 at 7:06 am

    If you want to use the new HTML5 way this is how I did it… keep in mind that I made a method called File() and this is not a true HTML5 method its a wrapper to it… this might be changed in the future so beware (maybe rename it).

    HTML:

      <html>
        <body>
          <input type="file" id="files" name="file"/> 
          <button onclick="load()">Load File</button><br /><br />
          <div id="content"></div>
          <script>
            function load() {
              var fileObj = document.getElementById("files");
              var fp = new File(fileObj);
              fp.read(callback);
            }
            function callback(text) {
              var content = document.getElementById("content");
              content.innerHTML = text;
            }
          </script>
        </body>
      </html>
    

    JavaScript:

    function File(name) {
      this.name = document.getElementById(name) ? document.getElementById(name).files : name.files ? name.files : name;
    }
    
    // Reads the file from the browser 
    File.prototype.read = function(callback) {
      var files = this.name;
      if (!files.length) {
        alert('Please select a file!?');
        return;
      }
      var file = files[0];
      var reader = new FileReader();
      reader.onloadend = function(evt) {
        if (evt.target.readyState == FileReader.DONE) { // DONE == 2
          callback(evt.target.result);
        }
      };
      var data = file.slice(0, file.size);
      reader.readAsBinaryString(data);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen two commonly used techniques for adding the directory of the file
So I understand the basic techniques that are used in branch prediction for pipelined
When using Comet, or Ajax Long Pull techniques - an iframe is usually used.
I have a question about DFA minimization. So I've used very well known techniques
>>> w ['Parts-of-speech', 'disambiguation', 'techniques', '(', 'taggers', ')', 'are', 'often', 'used', 'to', 'eliminate', '(',
What techniques could I use to make my jar file Reverse Engineer proof?
As far as I know, these days there are two main techniques used for
I've used a lot of other techniques for reading pixel data from files but
I want to load some data from mysql into my cocoa application view before
I have been reading for a while the different techniques used to texture terrains

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.