o madonna... era tutto qui il problema?!
codice:
<!doctype html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Esempio</title>
<script type="text/javascript">
var sMimeType;
function fileLoaded(frEvnt) {
var sFBody = frEvnt.target.result;
var sBodyBase64 = btoa(sFBody);
var sHTMLCode = "<img src=\"data:" + sMimeType + ";base64," + sBodyBase64 + "\" \/>";
document.miaForm.uscitaBin.value = sFBody;
document.miaForm.uscitaB64.value = sBodyBase64;
document.miaForm.uscitaHTML.value = sHTMLCode;
document.getElementById("risultatoHTML").innerHTML = sHTMLCode;
}
function loadImageFile() {
var oFile = document.getElementById("mioFile").files[0];
if (oFile) {
var oFReader = new FileReader();
oFReader.onload = fileLoaded;
sMimeType = oFile.type;
oFReader.readAsBinaryString(oFile);
}
}
function ciao() {
alert("oij");
}
</script>
</head>
<body>
<form name="miaForm" onsubmit="return(false);">
<table>
<tbody><tr>
<td>Seleziona un'immagine:</td>
<td><input type="file" id="mioFile" onchange="loadImageFile();" /></td>
</tr><tr>
<td>Output binario:</td>
<td><textarea name="uscitaBin" style="width: 400px; height: 100px;"></textarea></td>
</tr><tr>
<td>Output base64:</td>
<td><textarea name="uscitaB64" style="width: 400px; height: 100px;"></textarea></td>
</tr><tr>
<td>Output HTML:</td>
<td><textarea name="uscitaHTML" style="width: 400px; height: 100px;"></textarea></td>
</tr><tr>
<td>Risultato HTML:</td>
<td><div id="risultatoHTML"></div></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>