I find this example in w3school to get display the file path of the file uploaded.
I need to get the chose file path using php.
I've added "form" with method "Post" and submit button to try to read javascript value but no result
"Try it" button call javascript function and I wanna "submit" get the same data as "Try it" button
<!DOCTYPE html>
<html>
<body>
<form action="" method = "post" enctype="multipart/form-data">
Select a file to upload:
<input type="file" id="myFile" size="50">
<p>Click the button below do the display the file path of the file upload button above (you must select a file first).</p>
<button type="button" onclick="myFunction()">Try it</button>
<p id="demo" name="demo" type="text"></p>
<input type="submit" name="submit" value="Submit" />
</form>
<script type="text/javascript">
function myFunction() {
var x = document.getElementById("myFile").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<?php
if(isset($_POST["submit"]))
{
$loc = $_GET["demo"];
echo $loc;
}
?>