0

How can I get full path for a <input type="file">

The below example gives only the file name but not path from where it is uploaded(ex: c:/abc/x.txt).

Any hint would help. Here is the fiddle

function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah').attr('src', e.target.result);
            }

            reader.readAsDataURL(input.files[0]);
        }
    }

    $("#imgInp").change(function(){
        readURL(this);
    });
Charlie
  • 22,886
  • 11
  • 59
  • 90
Kurkula
  • 6,386
  • 27
  • 127
  • 202
  • 1
    this may help you http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav – M14 Nov 25 '16 at 05:56
  • tried this. its give only file name and its properties. – Kurkula Nov 25 '16 at 05:58

1 Answers1

-1

Try this (javascript)

$(function () {
    $('#fileSelected').on('change', function (evt) {
        var files = $(evt.currentTarget).get(0).files;

        if(files.length > 0) {
            console.log("Ok");
            $('#fileName').text(files[0].name);
            $('#fileSize').text(files[0].size);
            $('#filePath').text($('#fileSelected').val());
        }
    });
});
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335