Skip to content

Instantly share code, notes, and snippets.

View andreafortuna's full-sized avatar

Andrea Fortuna andreafortuna

View GitHub Profile
@andreafortuna
andreafortuna / HTML5MediaCapture.html
Created May 24, 2013 21:29
HTML5: accedere alla videocamera e alla galleria di foto dei dispositivi mobili
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>HTML5 Media Capture Demo</title>
<script type="text/javascript" charset="utf-8" src="jquery-2.0.0.min.js"></script>
</head>
// Create an image
var img = document.createElement("img");
// Create a file reader
var reader = new FileReader();
// Set the image once loaded into file reader
reader.onload = function(e)
{
img.src = e.target.result;
img.onload = function() {
<!DOCTYPE html>
<html>
<head>
<title>Take or select photo(s)</title>
<script type="text/javascript">
function fileSelected() {
var count = document.getElementById('fileToUpload').files.length;
document.getElementById('details').innerHTML = "";
for (var index = 0; index < count; index ++)
{
<?php
if (isset($_FILES['myFile'])) {
// Example:
move_uploaded_file($_FILES['myFile']['tmp_name'], "uploads/" . $_FILES['myFile']['name']);
echo 'Upload completed!';
}
?>
function doUpload() {
var file = document.getElementById('fileToUpload').files[0];
var dataUrl = "";
// Create an image
var img = document.createElement("img");
// Create a file reader
var reader = new FileReader();
// Set the image once loaded into file reader
reader.onload = function(e)
{
<?php
if (isset($_POST['image'])) {
file_put_contents("uploads/".rand().".png",base64_decode(str_replace("data:image/png;base64,","", $_POST['image'])));
echo 'Upload completed!';
}
?>
var myWorker = new Worker('/path/operazioniDaEseguire.js');
myWorker.onmessage = function(event) {
console.log('Fatto, ecco i dati!', event.data);
};
@andreafortuna
andreafortuna / postmessage.js
Created February 7, 2016 14:40
postmessage.js
//stepsToBeMade.js
postMessage("So long, and thanks for all the fish.");
<script id="myWorker">
var i = 0;
setInterval(function() {
i++;
postMessage(i);
}, 1000);
</script>