2016-01-28 32 views
0

有没有办法在文件被选择到文本输入字段后插入文件的路径?在文本输入字段中插入上传文件的路径

Select images: <input type="file"> 
File path here: <input type="text"> 

我做了一个摆弄一个例子:https://jsfiddle.net/5by18xon/

+3

@see的http://计算器。 com/questions/3704009/input-file-field-to-input-text-field –

+0

请注意,有些浏览器可能会阻止访问出于安全原因。同样在服务器上,当你得到的文件的路径文件的一部分可能是假的。因此,你为什么要文件名? – scunliffe

回答

0

是您可以使用输入文件change事件:

$('input[type="file"]').change(function(){ 
 
    $('input[type="text"]').val($(this).val()); 
 
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
Select images: <input type="file"><br><br> 
 
File path here: <input type="text">

相关问题