When using webkitRelativePath is the path separator operating system specific?

Viewed 519

I'm trying to implement a directory upload feature with limited browser support (namely Chrome or Chromium based browsers). To that end I'm using an HTMLInput element with the webkitdirectory attribute. What I need to know is will the directory separators in the webkitRelativePath property of the selected File objects use operating system specific directory separators. It looks like according to this W3C draft it is specified to always be unix style separators, but it would be good to have confirmation of this (if possible for FireFox as well). Unfortunately the MDN documentation doesn't specify.

Here is a snippet that demonstrates the functionality:

var dirInput = document.getElementById('dirInputTest');
var output = document.getElementById('dirListing');
dirInput.addEventListener(
  'change',
  function () {
    var files = Array.from(dirInput.files);
    output.innerHTML = '';
    for (var i = 0; i < files.length; i++) {
      output.innerHTML += files[i].webkitRelativePath + '\n';
    }
  }
);
<body>
<input id="dirInputTest" type="file" webkitdirectory />
<pre id="dirListing">
</pre>
</body>

1 Answers

So I got around to spinning up a Windows VM and I can confirm that all of the major browsers (Chrome, Fire-Fox, Edge) use the forward slash path separator regardless of operating system (I did not test Opera or Internet Explorer).

Related