Created
November 18, 2016 06:36
-
-
Save PUSRISTEK/359f3c8a9f43e6ef90aad6e332c117e8 to your computer and use it in GitHub Desktop.
How to Upload Multi Files
This file contains hidden or 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
<form action="" method="post" enctype="multipart/form-data"> | |
<p>Pictures: | |
<input type="file" name="pictures[]" /> | |
<input type="file" name="pictures[]" /> | |
<input type="file" name="pictures[]" /> | |
<input type="submit" value="Send" /> | |
</p> | |
</form> | |
<?php | |
foreach ($_FILES["pictures"]["error"] as $key => $error) { | |
if ($error == UPLOAD_ERR_OK) { | |
$tmp_name = $_FILES["pictures"]["tmp_name"][$key]; | |
// basename() may prevent filesystem traversal attacks; | |
// further validation/sanitation of the filename may be appropriate | |
$name = basename($_FILES["pictures"]["name"][$key]); | |
move_uploaded_file($tmp_name, "data/$name"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment