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>
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
Atualizar Debian Online de uma Versão para outra
Instalando Discord no Debian 13
Instalar driver Nvidia no Debian 13
Redimensionando, espelhando, convertendo e rotacionando imagens com script
Layout do teclado KDE Palsma 5.27.5 com x11 (1)
O que você está ouvindo agora? [2] (216)