Created
September 30, 2015 16:10
-
-
Save sdglhm/c72c59b8a0bbc586e5bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<form method="post" enctype="multipart/form-data" id="upload_form"> | |
<input type="button" value="Add" onclick="addUploader()"> | |
<div id="upload_div"> | |
<input type="file" accept="image/*" name="upload[]"> | |
</div> | |
<input type="submit" value="Upload files"> | |
</form> | |
<script> | |
function addUploader () { | |
var dv = document.getElementById("upload_div"); | |
var newp= document.createElement("p"); | |
dv.appendChild(newp); | |
newp.innerHTML='<input type="file" name="upload[]" accept="image/*" />'; | |
} | |
</script> | |
<hr/> | |
<?php | |
for ($i=0; $i < count($_FILES['upload']['name']); $i++) { | |
$extention = pathinfo($_FILES['upload']['name'][$i],PATHINFO_EXTENSION); | |
move_uploaded_file($_FILES['upload']['tmp_name'][$i] , "a-file-" . microtime() . "-" . $i . "." . $extention ); | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment