br1 grazie per la risposta ma quando copio ed incollo il codice in questo forum mi mette tutti gli a capo sbagliati non so perchè comunque ho provato anche a sistemare un pò gli a capo, come ta tuo consiglio ma non cambia nulla.
per cavicchiandrea e se fosse proprio il filereader che non è supportato dal mobile/android cosa potrei utilizzare ?
Codice PHP:
<script language="javascript" >
// RESIZE AND UPLOAD
if (window.File && window.FileReader && window.FileList && window.Blob) { document.getElementById('filesToUpload').onchange = function(){ var files = document.getElementById('filesToUpload').files; for(var i = 0; i < files.length; i++) { resizeAndUpload(files[i]); } };} else { alert('The File APIs are not fully supported in this browser.');} function resizeAndUpload(file) {var reader = new FileReader(); reader.onloadend = function() { var tempImg = new Image(); tempImg.src = reader.result; tempImg.onload = function() { var MAX_WIDTH = 800; var MAX_HEIGHT = 600; var tempW = tempImg.width; var tempH = tempImg.height; if (tempW > tempH) { if (tempW > MAX_WIDTH) { tempH *= MAX_WIDTH / tempW; tempW = MAX_WIDTH; } } else { if (tempH > MAX_HEIGHT) { tempW *= MAX_HEIGHT / tempH; tempH = MAX_HEIGHT; } } var canvas = document.createElement('canvas'); canvas.width = tempW; canvas.height = tempH; var ctx = canvas.getContext("2d"); ctx.drawImage(this, 0, 0, tempW, tempH); var dataURL = canvas.toDataURL("image/jpeg"); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(ev){ document.getElementById('filesInfo').innerHTML = 'Upload OK!'; }; xhr.open('POST', 'UploadImages.php', true); xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); var data = 'image=' + dataURL; xhr.send(data); } } reader.readAsDataURL(file);}
</script>