I want to achieve the following.
<video src="file:///Users/username/folder/video.webm">
</video>
The intent is that the user will be able to select a file from his/her hard drive.
And the reason for not uploading is of course transmission costs and storage quota. There will be no reason to save the file.
Is it possible?
It is possible to play a local video file.
When a file is selected via the
input
element:input.files
FileListvideo.src
propertyLean back and watch :)
http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/
That will be possible only if the HTML file is also loaded with the
file
protocol from the local user's harddisk.If the HTML page is served by HTTP from a server, you can't access any local files by specifying them in a
src
attribute with thefile://
protocol as that would mean you could access any file on the users computer without the user knowing which would be a huge security risk.As Dimitar Bonev said, you can access a file if the user selects it using a file selector on their own. Without that step, it's forbidden by all browsers for good reasons. Thus, while his answer might prove useful for many people, it loosens the requirement from the code in the original question.
Ran in to this problem a while ago. Website couldn't access video file on local PC due to security settings (understandable really) ONLY way I could get around it was to run a webserver on the local PC (server2Go) and all references to the video file from the web were to the localhost/video.mp4
Not an ideal solution but worked for me.