how to remove c fakepath in webkit browser like chrome, safari, opera?
css, google-chrome, html, javascript, safari
Solution
Just use a regular expression to remove everything before (and including) the last `\`.
var path = "C:\\fakepath\\example.doc";
var filename = path.replace(/^.*\\/, "");
console.log(filename);
Obviously, you'd get `path` from your file input.
Problem
How to remove c fakepath in webkit browser like chrome, safari, opera ? in IE And Firefox it's show only file name , it's OK But in Chrome, opera, safari. It's show C:\fakepath\700.jpg How can i remove C:\fakepath\ in Chrome, opera, safari. ``` <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script> <style type="text/css"> .inputWrapper { overflow: hidden; position: relative; cursor: pointer; /*Using a background color, but you can use a background image to represent a button*/ background-color: #DDF; } .fileInput { cursor: pointer; height: 100%; position:absolute; top: 0; right: 0; /*This makes the button huge so that it can be clicked on*/ font-size:50px; } .hidden { /*Opacity settings for all browsers*/ opacity: 0; -moz-opacity: 0; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0) } </style> <script type="text/javascript">//<![CDATA[ $(window).load(function(){ $(function() { $(".inputWrapper").mousedown(function() { var button = $(this); button.addClass('clicked'); setTimeout(function(){ button.removeClass('clicked'); },50); }); $('input[type=file]').change(function() { var $this = $(this); $this.parent().find('span').text($this.val()); }); }); });//]]> </script> <div class="inputWrapper" id="inputWrapper" style="height: 56px; width: 128px;"> <input class="fileInput hidden" type="file" name="file2"/> <span></span> </div> ```