Code: Select all
<!-- attachments start -->
<br>
<input type="file" name="attachment" id="attachment" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
<div id="moreUploads"></div>
<div id="moreUploadsLink" style="display:none;"><a href="javascript:addFileInput('moreUploads');">Attach another File</a></div>
<!-- attachments end -->
Code: Select all
<script language="javascript" type="text/javascript">
//add/remove upload files
var upload_number = 1;
function addFileInput(i) {
if(upload_number > 10) { return; } //no more than 10
var d = document.createElement("div");
var l = document.createElement("a");
var file = document.createElement("input");
file.setAttribute("type", "file");
file.setAttribute("name", "attachment"+upload_number);
l.setAttribute("href", "javascript:removeFileInput('f"+upload_number+"');");
l.appendChild(document.createTextNode("Remove"));
d.setAttribute("id", "f"+upload_number);
d.appendChild(file); d.appendChild(l);
document.getElementById(i).appendChild(d); upload_number++;
}
function removeFileInput(i) {
var elm = document.getElementById(i);
document.getElementById("moreUploads").removeChild(elm);
upload_number = upload_number - 1; // decrement the max file upload counter if the file is removed
}
</script>
Something like this could easily be added in for images, the PHP backend code is already pretty much there to handle multiple files (may need a little tweaking), it's just the frontend HTML that lacks the support.
This is an idea for 0.8.
Comments welcome.