browse for file in javascript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dvdljns
    New Member
    • Jul 2013
    • 3

    #1

    browse for file in javascript?

    I have a script that replaces the content of a container on a webpage. What I would like to do is browse to a file and select it. What I do now is type the info in but would like to automate it more. In asp I can browse to a file from my admin page select the file and it posts the first few lines of the text with a more link. can I do this in javascript?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    are you talking about files on a server or files on your local machine?

    for the former, you need a server side language for assistance, for the latter, hm, not through the browser. but tdifferent OS’s have the possibility to write desktop apps in JS.

    Comment

    • dvdljns
      New Member
      • Jul 2013
      • 3

      #3
      On my webserver. It is in my home but I get to it by www. Can't I browse for a file in java script. Maybe something like this
      Code:
      function openfile(file) {
      
      window.location = "file:///" + file;
      I Know it has this
      Code:
      <input type="file">
      but not sure how to work it.
      Maybe I am going at this wrong? I have a script that changes the text in a container on my webpage but I have to navigate to the folder and open the script and type in the text hit a button that changes the text. If I have 6 text areas about 6 things I do it 6 times. I want to do this from 1 page instead of 6.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        On my webserver.
        client-side JavaScript cannot do work on the server, period. (think of what would happen if you (resp. anyone else) could)

        Code:
        function openfile(file) {
        window.location = "file:///" + file;
        that is not related to a webserver (they use HTTP), however, check out the FileReader API.

        Comment

        Working...