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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:29:21+00:00 2026-05-27T20:29:21+00:00

How do I get the contents of a file form a HTML form? Here

  • 0

How do I get the contents of a file form a HTML form? Here is an example of what I’m working with. All it does it output something like “C:\Fake Path\nameoffile

<html>
<head>

<script type="text/javascript">
    function doSomething(){
        var fileContents = document.getElementById('idexample').value;
        document.getElementById('outputDiv').innerHTML = fileContents;
    }
</script>

</head>
<body >

<form name = "form_input" enctype="multipart/form-data">

<input type="file" name="whocares" id="idexample" />
<button type="button" onclick="doSomething()">Enter</button>

</form>

<div id="outputDiv"></div>

</body>
</html>

EDIT:
It seems the solution is difficult to implement this way. What I’m trying to accomplish is sending a file to a python script on my webserver. This is my first time trying this sort of thing so suggestions are welcome. I supposes I could put the python script in my cgi folder and pass the values to it using something like…

/cgi/pythonscript.py?FILE_OBJECT=fileobjecthere&OTHER_VARIABLES=whatever

Would this be a better solution for sending file content to a webserver rather than having javacript open it directly using FileReader?

  • 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-05-27T20:29:22+00:00Added an answer on May 27, 2026 at 8:29 pm

    You can actually do that with the new FileReader Object.

    Try this working example

    function doSomething()
    {
        var file = document.getElementById('idexample');
    
        if(file.files.length)
        {
            var reader = new FileReader();
    
            reader.onload = function(e)
            {
                document.getElementById('outputDiv').innerHTML = e.target.result;
            };
    
            reader.readAsBinaryString(file.files[0]);
        }
    }
    

    (works with the newest versions of Chrome and Firefox)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got my little html fisher working and it grabs a text file form
I'm trying to get file contents, replace some parts of it using regular expressions
I'm trying to get the contents from another file with file_get_contents (don't ask why).
So in all my failed attempts to get jQueryUI working, I have tried this
I have tried using fopen, file-get-contents and a curl request but I always get
There is an HTML file (whose contents I do not control) that has several
I'm using file_get_contents('mysourcefile.html') to load the contents of mysourcefile.html into mysql db. I have
Using javascript, how to open a text-file or html-file from a web-page and load
HTML <form action='insert.php' method='POST'> <p><b>Client:</b><input type='text' name='idclient'/> <p><b>Total:</b><br /><input type='text' name='total'/> <p><input type='submit' value='Save'
I have an HTML form on my site that submits via Ajax to a

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.