I have been looking for an answer & reading since 24hrs that for security reasons this is not allowed by most of the browser but
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.
I am able to get the name of the file but not the path.
How do I get the path of the selected file?
<script type="text/javascript">
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
}
</script>
<form action="vanilla.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();">
</form>
OR you can suggest any other way to upload a file using PHP
Thanks!