how to upload multiple files in php
how to upload multiple files in php |
please follow the below step to learn how to upload multiple files in php..
step 1:
create 2 files and 1 folder named:
1. index.php
2. style.css
folder name images
Now copy and save the below codes for different files..
1. index.php
index page to display upload form and processing the upload selected file..
<html> <head> <title>PHP Image Upload</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <div id="form"> <h2>Upload Multiple file using PHP</h2> <form method="post" action="" enctype="multipart/form-data"> <input type="file" name="image[]" multiple/> <input type="submit" name="submit" value="Upload"/> </form> <div id="image"> <?php //Folder $target='images/'; if(isset($_POST['submit'])){ foreach($_FILES['image']['name'] as $key=>$value){ $path=$target.basename($_FILES['image']['name'][$key]); $name=$_FILES['image']['name'][$key]; //Moving File $upload=move_uploaded_file($_FILES['image']['tmp_name'][$key],$path); if($upload){ echo '<ul><li><img src=images/'.$name.'></li></ul>'; }else{ echo 'Failed'; } } } ?> </div> </div> </html>
2. style.css
style page to design our index page
#form{ width:700px; background:#42f48c; padding:5px 8px; border-radius:5px; margin:auto; overflow:hidden; } input[type=file]{ padding:5px 0px 5px 5px; background:black; border-radius:5px; } input[type=submit]{ background:black; color:white; padding:6px 8px; font-weight:bold; cursor:pointer; border-radius:5px; } ul{ list-style:none; } ul li{ float:left; margin-left:5px; } #image img { padding: 3px; box-shadow: 0 1px 3px ; border: 1px solid black; border-radius:3px; margin-top:0px; float:left; width:150px; height:200px; }
That's it Friends how to upload multiple files in php ..if you like this post please share with your friends ..Thank you..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.