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 6897515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:10:42+00:00 2026-05-27T07:10:42+00:00

I am trying to upload multiple files to my server. If I try to

  • 0

I am trying to upload multiple files to my server. If I try to upload a single file, it works fine. but if I try more than one, it gives me an error code 4, even though it does print the name of all the files correctly. Nothing is uploaded. I have the input type set correctly. Can someone help me?

Choose Image:&nbsp;&nbsp;<input name="uploadedfile[]" type="file" multiple="true"/><br /><br /><br />
            <input type="submit" value="Upload Image!" style="margin-left:100px;"/>

Below is the code:

$i=0;
foreach($_FILES['uploadedfile']['name'] as $f)
{
    $file['name'] = $_FILES['uploadedfile']['name'][$i];
    $file['type'] = $_FILES['uploadedfile']['type'][$i];
    $file['tmp_name'] = $_FILES['uploadedfile']['tmp_name'][$i];
    $file['error'] = $_FILES['uploadedfile']['error'][$i];
    $file['size'] = $_FILES['uploadedfile']['size'][$i];
    if ($file["error"] > 0)
    {
        echo "Error Code: " . $file["error"];
    }

    $target_path = "uploads/".basename($file["name"]); 

    if(move_uploaded_file($file["tmp_name"], $target_path)) 
    {
        echo basename($file['name'])."<br />";
        echo basename($file['tmp_name'])."<br />";
        echo $target_path;

    } else{
        echo "There was an error uploading the file, please try again!";
    }
    $i++;
}

and my HTML form

<div id="album_slider">
    <div style="text-align:center;margin:20px auto;font-size:27px;">Upload Image</div>
    <br style="clear:both;font-size:0;line-height:0;height:0;"/>
    <div style="width:700px;margin:auto;height:250px;text-align:left;">
        <form enctype="multipart/form-data" action="uploader.php" method="POST" name="form">
            Image Name:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="image_name" id="image_name"/><br /><br /><br />
            <input type="hidden" name="a_id" id="a_id" value="<?php echo $a_id; ?>"/>
            Choose Image:&nbsp;&nbsp;<input name="uploadedfile[]" type="file" multiple="true"/><br /><br /><br />
            <input type="submit" value="Upload Image!" style="margin-left:100px;"/>
        </form>
    </div>
    <br style="clear:both;font-size:0;line-height:0;height:1px;"/>
</div>
  • 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-05-27T07:10:42+00:00Added an answer on May 27, 2026 at 7:10 am

    Try:

    foreach ($_FILES["uploadedfile"]["error"] as $key => $error) {
       if ($error == UPLOAD_ERR_OK) {
           echo "$error_codes[$error]";
           move_uploaded_file(
             $_FILES["uploadedfile"]["tmp_name"][$key],
             $target_path
           ) or die("Problems with upload");
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload multiple files but when i select more than 1
I am trying to upload a text file with more than one record but
I am trying to upload some files using the multiple upload file field. The
I'm trying to a upload file (or multiple files) to my servlet, which is
I'm trying to upload multiple files via a form, but I can only upload
I'm trying to upload multiple files at once with Play Framework, but I always
I'm trying to upload several files at once from ONE input : <input type=file
I am trying to write a PHP script that can upload multiple files. for($i=0;$i<count($_FILES['uploadimg']['name']);$i++){
I am using Codeigniter and I am trying to upload multiple files into a
I am trying to use the multiple upload attribute of HTML5 to upload files.

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.