Created
August 28, 2019 08:36
-
-
Save shashank-p/d09faacafc1fa017c0cacac18fce0483 to your computer and use it in GitHub Desktop.
PHP Multiple Image Upload
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
<!doctype html> | |
<html> | |
<head> | |
<title>Test</title> | |
</head> | |
<body> | |
<form method="post" enctype="multipart/form-data"> | |
<input type="file" name="my_file[]" multiple> | |
<input type="submit" value="Upload"> | |
</form> | |
<?php | |
if (isset($_FILES['my_file'])) { | |
$myFile = $_FILES['my_file']; | |
$fileCount = count($myFile["name"]); | |
$dest = "upl/"; | |
for ($i = 0; $i < $fileCount; $i++) { | |
?> | |
<p>File #<?= $i+1 ?>:</p> | |
<p> | |
Name: <?= $myFile["name"][$i] ?><br> | |
Temporary file: <?= $myFile["tmp_name"][$i] ?><br> | |
Type: <?= $myFile["type"][$i] ?><br> | |
Size: <?= $myFile["size"][$i] ?><br> | |
Error: <?= $myFile["error"][$i] ?><br> | |
</p> | |
<?php move_uploaded_file($myFile["tmp_name"][$i], $dest.$myFile["name"][$i]); ?> | |
<?php | |
} | |
} | |
?> | |
</body> | |
</html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment