Reading file contents into the textarea using javascript....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aryanraj
    New Member
    • Feb 2008
    • 4

    Reading file contents into the textarea using javascript....

    Hi Everybody,

    I want to design an html file viewer, for that i have got the code to browse the file, but i am not able to read the contents of the selected file, can anybody help to open the file and read it contents and display the content into the textarea.



    Thanks in advance,
    Aryan.
  • wyatt
    New Member
    • Feb 2008
    • 6

    #2
    If you want to read text from a file supplied by the user, you will need to use a server-side language, as it is beyond the capability of Javascript.

    If you're interested, I can provide you with PHP code which will accomplish this.

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      Originally posted by wyatt
      If you want to read text from a file supplied by the user, you will need to use a server-side language, as it is beyond the capability of Javascript.

      If you're interested, I can provide you with PHP code which will accomplish this.

      you can point an iframe's src to the local text file's url to display it.

      you cannot load local files in js until firefox3 comes out.

      using IE, with proper security settings, this can be done using FSO.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Originally posted by aryanraj
        Hi Everybody,
        I want to design an html file viewer, for that i have got the code to browse the file, but i am not able to read the contents of the selected file, can anybody help to open the file and read it contents and display the content into the textarea.

        Thanks in advance,
        Aryan.
        I would like to add something to the previous post.
        When you sure sure that your application runs (client side) on Internet Explorer, you can use (as said) the FileSystemObjec t (FSO) to read and manipulate files. Better see Working with FileSystemObjec t - Files

        Ronald

        Comment

        • aryanraj
          New Member
          • Feb 2008
          • 4

          #5
          Ok i can understand it, can you please give me the code in PHP to read the file contents...

          Comment

          Working...