0

Nomally web browser would not allow a website to access the users local files. I came across locallinks plugin which allows the file:/// access from a webpage , however such file opens up in a different tab.

I wanted to create a player which already has information about the file location on a clients computers and would play the media file on being clicked.I have coded something like this

<audio controls="" id="player">
<source src="file:///home/vihaan/Music/001) Led Zeppelin - Stairway to Heaven.mp3" type="audio/mp3"/>
Your browser does not support html 5 audio
</audio> 

I had assumed that installing that plugin would make this work ! I have also heard about NPAPI plugins. Would it be possible to create a plugin which after the webpage gets loaded allows reading a file into the webpage i.e playmusic from a users computer without the user actually have to select the folder every time. Thanks

Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
  • 2
    DOn't try it. In your case, it's just a MP3 file. But what if the location is eg. a private key file? Allowing web pages to read arbitrary files from the user's filesystem is extremely dangerous. – Rob W Sep 01 '12 at 19:26

1 Answers1

1

It would absolutely be possible to do this with an NPAPI plugin; it would most likely be a very, very bad idea.

There is a reason that browsers have those security restrictions in place; if you allow your web page to read arbitrary data on a user's computer then suddenly any other website could just use your same plugin to do the same thing; and they might not be just reading music. Bare minimum you'd need some very careful restrictions on it, and even then you'd likely open up a security hole that you aren't aware of by accident. You don't want to be known as the creator of the plugin that allowed the next botnet to take over.

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • Another issue is see with this things is that even if I make such a plugin, how will the audio tag read it or will it read it or is it possible that this things will work :\ – Vihaan Verma Sep 03 '12 at 01:37
  • you can't modify the behavior of the audio tag; you could just make it possible for javascript to do things (through help of an object tag) that it can't normally do. again, very dangerous – taxilian Sep 03 '12 at 07:06