0

All I get is the images name not the file tree like

C:/document/picture/dangit.gif

Okay, I need to add more text for some reason because stack overflow thinks that I should type more then I need to type so just ignore this text this is so retarded.

<html>
  <head>
    <script>
      function getData() {
        var text = document.getElementById("textarea").value;
        var text = text.replace(/\r?\n/g, "<br />");
        document.getElementById("display").innerHTML = text;
      }

      function picture() {
        var picture = document.getElementById("picture").value;
        document.getElementById("pDisplay").src = picture;
        document.getElementById("purl").innerHTML = picture;
      }
    </script>
    <title>Gettings a textbox formatting</title>
  </head>
  <body>
    <textarea id="textarea" onkeypress="getData()" autofocus></textarea>
    <p id="display">You havnt typed anything yet</p>
    <input type="file" id="picture" />
    <button onclick="picture()">get the picture from the box</button>
    <p id="purl">picture url</p>
    <img id="pDisplay" />
  </body>
</html>
Mario Petrovic
  • 4,128
  • 5
  • 26
  • 43
get52
  • 51
  • 1
  • 9

3 Answers3

0

That's impossible because javascript can't access local storage like hard disk.

The only option is to upload image to the server and then reference it with URL.
If you are using PHP you could start with the documentation http://www.php.net/manual/en/features.file-upload.php
And you need to enclose your <input type="file"> with <form> and provide <input type="submit"> to send the file to the server.

ElmoVanKielmo
  • 9,272
  • 2
  • 28
  • 41
0

This is not possible due to security restrictions. JavaScript in browser has no access to the File System.

Yosi
  • 59
  • 3
0

It doesn't work on any of the main browsers (except IE) for security related restrictions

SaucyGuy
  • 54
  • 6