0

I wanted to make use of a file uploader that will open a file dialog box and when I will select a file, its location will be shown in a different textbox. I made the use of the below code in my View to display the file dialog. However, I am not able to display the location of the file that is chosan from the file dialog on a different textbox as the below code already have a pre defined label by the name "your text here" which displays the chosan file name after selection. How will I be able to display the location onto a different textbox and how should I be able to delete that predefined label appearing? Any help will be appreciated

<input type="file" id="upload"/>
Running Rabbit
  • 2,634
  • 15
  • 48
  • 69

3 Answers3

0

Use following code for get full path of your selected file

<input id="myFileUpload" type="file"/>
<input id="textbox" type="text"/>
<script type="text/javascript">
    $(function () {
        $('#myFileUpload').change(function () {
            $("#textbox").val($('#myFileUpload').val())
        });
    });
</script>

and read following article to hide built in lable in file uploader Hide lable in file input

Community
  • 1
  • 1
Hamed Khatami
  • 525
  • 1
  • 5
  • 14
0

Phil Haack wrote a post on this subject, Uploading a File (Or Files) With ASP.NET MVC.

Md Nazmoon Noor
  • 3,187
  • 1
  • 24
  • 30
0

Hi please do not waste your time on this it's not possible.

Read this: How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?

Try like this, but it's not display path value on text box,

$('input[type=file]').change(function () {
    console.log(this.files[0].mozFullPath);
});
Community
  • 1
  • 1
Jaimin
  • 7,964
  • 2
  • 25
  • 32