Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9035461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:45:51+00:00 2026-06-16T08:45:51+00:00

i have a form which is able to upload multiple selected files to the

  • 0

i have a form which is able to upload multiple selected files to the folder. I just need to find how how to insert them into the database using PHP?

HTML form

<form name="demoFiler" id="demoFiler" enctype="multipart/form-data">
<input type="file" name="multiUpload" id="multiUpload" multiple />
<input type="submit" name="submitHandler" id="submitHandler" value="Upload" class="buttonUpload" />
</form>

PHP code

if($_SERVER['REQUEST_METHOD'] == "POST"){
    if(move_uploaded_file($_FILES['file']['tmp_name'], "uploads/".$_FILES['file']['name'])){
        echo($_POST['index']);
    }
    exit;
}

This is my code and first of all I can’t get the files to be moved to the upload folder:

<?php

$username = "root";
$password = "";
$host = "localhost";
$database = "db_holiday";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database);

if($_SERVER['REQUEST_METHOD']=="POST")
{
    foreach ($_FILES['multiUpload']['name'] as $fileName) { 
        $uploaddir= '/upload/';
    $uploadfile = $uploaddir . basename($fileName);
        if (move_uploaded_file($fileName, $uploadfile)) {
            echo "File is valid, and was successfully uploaded.\n";
        } else {
            echo "Possible file upload attack!\n";
        }
    }
}

?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="multiUpload[]" id="multiUpload" multiple="multiple" />
<input type="submit" name="button"/>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:45:53+00:00Added an answer on June 16, 2026 at 8:45 am

    Use 2 input type="file" elements

    <input type="file" name="img_1" />
    <input type="file" name="img_2" />
    

    Access each file using

    $_FILES['img_1'][];
    $_FILES['img_2'][];
    

    Or you can also use an array like

    <input type="file" name="img[]" />
    <input type="file" name="img[]" />
    <!--Which is often used in checkboxes-->
    

    And access each image using

    $_FILES['img']['tmp_name'][0];
    $_FILES['img']['tmp_name'][1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a form which allows the user to upload some files to a
I have a form that allow users to upload files, I however need to
I have a form which uploads multiple file fields into a db using codeigniter.
I'm building an HTML form with which the user should be able to upload
I made a website on which i need to be able to upload video
I have a form which I want to be 'resusable' for a variety of
I have a form which has a RichTextBox docked to the left and DataGridView
I have a form which POST's its data via AJAX: $.ajax({ type: POST, url:
I have a form which has three inputs when the page loads -- 2
We have a form which uses the JQuery Validation Plugin and would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.