如何在选择文件时获取文件的完整路径 <input type=‘file’>
<input type="file" id="fileUpload">
<script type="text/javascript">
function getFilePath(){
$('input[type=file]').change(function () {
var filePath=$('#fileUpload').val();
});
}
</script>
Run Code Online (Sandbox Code Playgroud)
但filePath var包含only name所选文件,而不是full path.
我在网上搜索过,但出于安全考虑,似乎浏览器(FF,chrome)只是给出文件名.
有没有其他方法来获取所选文件的完整路径?
我在php中有以下代码:
<?php
$apples = 123123;
echo "<td>
<input type='button' onclick='confirmation($apples)' value='ac/in'>
</td>";
echo('<script type="text/javascript">
function confirmation(test) {
var answer = confirm("Are you sure?")
if (answer){
alert(test);
$.get("/index.php?f=func_name_to_call",
{name: "John", hobby: "Programming"}, function(data) {});
}
}
</script>');
?>
Run Code Online (Sandbox Code Playgroud)
如果$ apples是一个数字,那么参数将被正确传递; 但是当它是一个字符串时,函数confirmation()被破坏.有任何想法吗?提前致谢.