
Enviado em 06/07/2013 - 23:03h
Olá!
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Upload com Ajax</title>
<link rel="stylesheet" href="/templates/css/global.css">
<script>
function upload (file) {
var sfb = document.querySelector('#selectFileButton');
var form = document.forms[0];
var file = document.querySelector('input[type=file]');
var prog = document.createElement('progress');
var fd = new FormData();
var xhr = new XMLHttpRequest();
xhr.open('POST', 'upload.php', true);
form.appendChild(prog);
form.removeChild(sfb);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var url = document.createElement('textarea');
url.innerHTML = xhr.responseText;
form.appendChild(url);
form.removeChild(prog);
}
}
xhr.send(fd);
}
onsubmit = function () {
return false;
}
</script>
</head>
<body>
<form method="POST" enctype="multipart/form-data">
<button type="button" id="selectFileButton" onclick="document.querySelector('input[type=file]').click()">Selecionar arquivo</button>
<input type="file" name="image" onchange="upload(this.files[0])">
</form>
</body>
</html>
Cinnamon seria a aposta acertada frente às outras interfaces gráficas mais populares?
KDE Plasma - porque pode ser a melhor opção de interface gráfica
Gentoo: detectando impressoras de rede e como fixar uma impressora por IP
Como o GNOME conseguiu o feito de ser preterido por outras interfaces gráficas
Por que sua empresa precisa de uma PKI (e como automatizar EMISSÕES de certificados via Web API)
Instalando NoMachine no Gentoo com Systemd (acesso Remoto em LAN)
Vou destruir sua infância:) (8)
Interface gráfica com problema (2)
Instalar Linux em notebook Sony Vaio VPCEG13EB (13)









