Path related problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mohammad Shoeb
    New Member
    • Aug 2010
    • 1

    Path related problem

    Sir, i want to display the file path that is selected after browsing in input type file control.
    Many ways i tried using post method but each time i get server side temporary path C:\wamp\tmp\php 55.tmp but i want local path such as C:\Documents and Settings\All Users\Documents \My Pictures\Sample Pictures\Sunset .jpg
  • pradeepkr13
    New Member
    • Aug 2010
    • 43

    #2
    That you can capture by javascript but I am not sure, never done. Check the content of
    <input type="file"> using javascript, save it in some hidden input field and pass it to php at server.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      the server is not the least interested in the file location on the client, all that matters is the data, thus you only get the file path on the server where that data is stored.

      Comment

      • pradeepkr13
        New Member
        • Aug 2010
        • 43

        #4
        working example :)

        Code:
        <html>
          <head>
          <script>
          function getLocalFilePath(id,target)
          {
            alert(document.getElementById(id).value);
            document.getElementById(target).value = document.getElementById(id).value 
          }
          </script>
          </head>
          <body>
        <form name="myform" onsubmit="javascript:getLocalFilePath('file','localfilepath');">
        <input type="hidden" name="localfilepath" id="localfilepath" value="">
        <input type="file" name="file" id="file">
        <input type="submit" name="submit">
        </form>
          </body>
        </html>

        Comment

        Working...