get source path of an image file from HTML input file tag : <p>I have been looking for an answer &amp; reading since 24hrs that for security reasons this is not allowed by most of the browser but</p>

<p>What I am trying to do - 
I want to upload an image using HTML input file tag. When I select the image using file browser, I want to get the path of the chosen file to work on it into the code.</p>

<p>I am able to get the name of the file but not the path.</p>

<p>How do I get the path of the selected file?</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function fileSelected(){
        var name = document.getElementById("fileToUpload").files[0].name;
        console.log(name); //gives the name of the selected file

        var val = document.getElementById("fileToUpload").files[0].value;
        console.log(val); //gives undefined
    }
&lt;/script&gt;


&lt;form action="vanilla.php" method="post" enctype="multipart/form-data"&gt;
    &lt;input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();"&gt;
&lt;/form&gt;
</code></pre>

<p>OR you can suggest any other way to upload a file using PHP</p>

<p>Thanks!</p>
