Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

file dialog on win32 returns backslashes in the path #551

Open
Gamadril opened this Issue · 0 comments

1 participant

@Gamadril

The paths returned by the file dialog should contain forward slashes instead of backslashes. Otherwise they are interpreted as escape charactes. Therefore you cannot just replace them all manually in JS code.

Testcase:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <input type="file" id="fileButton">
    <br>
    <image id="image"/>
    <br>
    <div id="imageCSS" style="width: 200px;height: 200px; background-size: 100% 100%;"></div>
    <script>
        document.getElementById('fileButton').addEventListener('change', function(event) {
            var filePath = event.target.files[0].path;
            console.log(filePath);
            document.getElementById('image').src = filePath; // works
            document.getElementById('imageCSS').style.backgroundImage = 'url(' + filePath + ')'; // error getting file
        }, false);
    </script>
</body>
</html>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.