<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script>
appendFileUploader = function() {
container = document.getElementById('GnuFileContainer');
var fileElementDiv = document.createElement('div');
fileElementDiv.innerHTML = '<input type="file" name="GnuFiles[]" value="" /> <input type="button" value="Fjern" onclick="removeFileUploader(this)">';
container.appendChild(fileElementDiv);
}
removeFileUploader = function(obj) {
document.getElementById('GnuFileContainer').removeChild(obj.parentNode);
}
getUploadersArray = function() {
var list = [];
elements = document.getElementById('GnuFileContainer').getElementsByTagName('input');
for(var i=0,len=elements.length;i<len;i++) {
if(elements[i].name == 'GnuFiles[]') {
list.push(elements[i]);
}
}
return list;
}
</script>
<body>
<form enctype="multipart/form-data" action="" method="POST">
<input type="button" onclick="appendFileUploader()" value="tilføj" />
<div id="GnuFileContainer"></div>
<input type="submit" value="send" onclick="alert('Uploader '+getUploadersArray().length+' fil(er)');"/>
</form>
<?php
if($_FILES) { print '<pre>'.print_r($_FILES['GnuFiles'],true).'</pre>'; }
?>
</body>
</html>
Her er alt hvad du skal bruge og kan komme på du skal bruge - Så må du selv finde ud af at gøgle dig frem til resten.