Skip to content

Instantly share code, notes, and snippets.

@pgdaniel
Created November 15, 2013 20:42
Show Gist options
  • Save pgdaniel/7491236 to your computer and use it in GitHub Desktop.
Save pgdaniel/7491236 to your computer and use it in GitHub Desktop.
vid uploads
<!DOCTYPE html>
1 <html>
2 <head>
3 <meta charset="utf-8">
4 <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
5 <body>
6 <input type="file" accept="/*" capture="camera"/>
7 <script>
8 var input = document.querySelector('input[type=file]');
9
10 input.onchange = function () {
11 var file = input.files[0];
12
13 displayAsVideo(file);
14 };
15
16 function displayAsVideo(file) {
17 var videoURL = URL.createObjectURL(file),
18 video = document.createElement('video');
19
20 video.onload = function() {
21 URL.revokeObjectURL(videoURL);
22 };
23
24 video.src = videoURL;
25 document.body.appendChild(video);
26 }
27 </script>
28 </body>
29 </html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment