0

I want to access file path obtained from browsing file using input tag. I want to display the path.

3

2 Answers 2

0

Here is an example using jquery:

<input type="file" id="input" />

$(document).ready(function() {
    $("#input").on("change", function() {
        alert($(this).val());
    });
});

I.e. $(this).val() contains the file path.

Here is a jsfiddle example http://jsfiddle.net/krasimir/uwaf2/

Sign up to request clarification or add additional context in comments.

Comments

0

From

Use jQuery to get the file input's selected filename without the path

$('input[type=file]').val()
var filename = $('input[type=file]').val().split('\\').pop();

or you could just do (because it's always C:\fakepath that is added for security reasons):

var filename = $('input[type=file]').val().replace(/C:\\fakepath\\/i, '')

Full path from file input using jQuery

You cannot read the full file path in js due to security reasons.

1 Comment

Is it "C:\fakepath\" on platforms other than Windows? I'd find it odd to see that path on Linux or Mac.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.