小编Yog*_*gle的帖子

如何在使用javascript,jquery-ajax更改<input type ='file'>时获取所选文件的完整路径?

如何在选择文件时获取文件的完整路径 <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)只是给出文件名.
有没有其他方法来获取所选文件的完整路径?

javascript jquery file-upload filepath

218
推荐指数
7
解决办法
66万
查看次数

为什么我不能在Javascript函数中传递字符串作为参数?

我在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()被破坏.有任何想法吗?提前致谢.

javascript php arguments function

2
推荐指数
1
解决办法
3724
查看次数

标签 统计

javascript ×2

arguments ×1

file-upload ×1

filepath ×1

function ×1

jquery ×1

php ×1