I'm trying to allow a user to select a file from their computer and start seeding it, I've followed the example here. I've used a normal input rather than using drag and drop as I couldn't get it to work.
Now whenever a file is selected I get this error:
Uncaught Error: filesystem paths do not work in the browser
How can I start seeding from a user's computer without uploading the file to my server?
I think you tryed reading a file with file:///
, but this not possible for security reasons. A file must be selected or drap&droped from the user.
The simplest solution is with a button:
function readFile(evt) {
var file = evt.target.files[0]
if (!file) {
return
}
var reader = new FileReader()
reader.onload = evt => {
var contents = evt.target.result
console.log(contents)
}
reader.readAsText(file)
}
<input type="file" onchange="readFile.call(this, event)" />
With this snippet you can read a file without any interaction with a server and thats ideal for a serverless techlology like torrent.