Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Multiple file upload in Php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 489
    Comment on it

    Hello Reader's today we discuss about "Multiple file upload using Php".

    Make sure that the shape employs method="post" The shape also desires the subsequent feature: enctype="multipart/form-data". This specifies which in turn content-type to utilize as soon as posting the form.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>Multiple File Upload</title>
    </head>
    <body>
      <form action="" method="post" enctype="multipart/form-data">
        <input type="file" id="file" name="files[]" multiple="multiple" accept="image/*" />
      <input type="submit" value="Upload!" />
    </form>
    </body>
    </html>
    
    
    
    <?php
        $path = "uploads/"; //folder name
        $count = 0;
    
        if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
        {
            // Loop $_FILES to exeicute all files
            foreach ($_FILES['files']['name'] as $f => $name)
            {         
                if($_FILES['files']['error'][$f] == 0)
                {
                    if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name))
                        $count++;         
                }
            }
            echo $count." "."file uploaded successfully!!!";
        }
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: