Created
December 4, 2015 02:18
-
-
Save Aziz-Rahman/6171a338118861745b1f to your computer and use it in GitHub Desktop.
Multiple upload
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
<?php | |
if(isset( $_FILES["gambar"] ) ){ | |
//Ulang di setiap file | |
for( $i=0; $i<count($_FILES["gambar"]["name"] ); $i++ ) { | |
//Deteksi temporari path $tmpFilePath = $_FILES["gambar"]['tmp_name'][$i]; | |
//Cek apakah file yang diupload lebih dari satu | |
if ( $tmpFilePath != "" ) { | |
//Set path/folder baru untuk tempat upload | |
$newFilePath = "files/" . $_FILES["gambar"]["name"][$i]; | |
//Upload file dari temporari path ke folder baru | |
$upload = move_uploaded_file( $tmpFilePath, $newFilePath ); | |
if ( $upload ) { | |
echo "sukses upload"; | |
} else { | |
echo "gagal upload"; | |
} | |
} | |
} | |
} | |
?> | |
<form action="" method="POST" enctype="multipart/form-data"> | |
<input type="file" name="gambar[]" multiple> <input type="submit"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment