0

Is there a way to insert the path of a file once it has been selected into a text input field?

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

I made a fiddle with an example: https://jsfiddle.net/5by18xon/

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • 3
    @see http://stackoverflow.com/questions/3704009/input-file-field-to-input-text-field – Petter Friberg Jan 28 '16 at 22:42
  • Be aware that some browsers may block access to do this for security reasons. Likewise on the server when you get the file part of the path to the filename may be fake. As such, why do you want the file name? – scunliffe Jan 28 '16 at 22:42

1 Answers1

0

Yes you can using change event on input file :

$('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">
Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101