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>
Comparação entre os escalonadores BFQ e MQ-Deadline (acesso a disco) no Arch e Debian
Conciliando o uso da ZRAM e SWAP em disco na sua máquina
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Converter os repositórios Debian para o novo formato com as chaves
Instalando Spotify no Debian 13
Realizar overclock no Miyoo Mini (plus ou normal)
linux mint reconhece microfone de lapela como fone de ouvido sem micro... (5)
E aí? O Warsaw já está funcionando no Debian 13? (2)
Dúvidas sobre a originalidade de conteúdos online (12)