Suzi Larsen
Suzi Larsen

Reputation: 1490

How to remove part of a string from a file name

I am using a bit of a workaround to the <input type="file">

You can see what I am doing here:

http://jsfiddle.net/susannalarsen/zU57Q/

The only problem I am having is that I cannot get rid of the C:\fakepath text that is appearing before any file I select.

How can I stop this from showing

Upvotes: 0

Views: 50

Answers (2)

Dean Meehan
Dean Meehan

Reputation: 2636

Not sure if the best possible answer but simply typing

.substring(12)

would remove the fakepath

$('#uploadme').change(function(){
    $('#filename').val($(this).val().substring(12));
});

http://jsfiddle.net/zU57Q/2/

Upvotes: 2

Joseph Marikle
Joseph Marikle

Reputation: 78520

You mean like this?

$('#filename').val($(this).val().replace(/.*\\/, ''));

http://jsfiddle.net/zU57Q/1/

Upvotes: 1

Related Questions