Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery string replace

Tags:

jquery

need help on this, trying to upload images from IE9 I get an C:fakepath/name_of_my_file

how do I remove this C:fakepath?

Thanks

if($('#ficheiro').val().search(/C:fakepath/)) {
                $('#ficheiro').val().val($('#ficheiro').val().replace('C:fakepath',''));
                nome.val('pics/'+$('#ficheiro').val());
            } else {
                nome.val('pics/'+$('#ficheiro').val());
            }
like image 787
Pluda Avatar asked Sep 14 '26 22:09

Pluda


1 Answers

You can use this and it will also remove the slashes leaving you just the filename.

$(this).val().replace(/C:\\fakepath\\/i, '');
like image 127
André Figueira Avatar answered Sep 17 '26 20:09

André Figueira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!