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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:29:36+00:00 2026-05-27T10:29:36+00:00

I cannot retrieve multiple files in my php code from $_FILES. Here is the

  • 0

I cannot retrieve multiple files in my php code from $_FILES.
Here is the input form:

<form enctype="multipart/form-data" action="file-upload.php" method="POST">
  Upload the several files:<input type="file" multiple="multiple" name="uploaded" id="id_upload" />
  <input type="submit" value="Upload" />
</form>

Here is the php code from file-upload.php:

 // first let's find out how many files were uploaded..
 $numUploadedfiles = count($_FILES['uploaded']);
 $num_FILES = count($_FILES); 
        // BOTH COUNTS ARE 5.  I SELECT 7 FILE NAMES FOR UPLOADING THOUGH.


 echo "<br>" . "The number of uploaded files is == " . $numUploadedfiles;
 echo "<br>" . "Here is the name of _FILES['uploaded']: " . $_FILES['uploaded'];
     // THE NAME REPORTED IS 'array' AND THE COUNT IS 5..


 echo "<br>" . "The count size of _FILES is == " . $num_FILES;
 echo "<br>" . "Here is the name of _FILES => " . $_FILES;
       // HERE ALSO, THE NAME REPORTED IS 'array' AND THE COUNT IS 5.


 echo "<br>file temp_name " . $i . " is: " . $_FILES['uploaded']['tmp_name'];
 echo "<br>file name " . $i . " is: " . $_FILES['uploaded']['name'];
        // THE NAME REPORTED HERE IS THE FILENAME OF LAST OF THE 7 FILES I UPLOADED (not sure why.)


 echo "<br>" . "Here are the filenames: ";
 for($i = 0; $i < $numUploadedfiles; $i++)
 {
    echo "<br>filename " . $i . " is: " . $_FILES['uploaded'][$i];
 }
 exit();

What happens when I run this is, when the ‘for’ loop starts, an error message saying that the $i indexes into the array _FILES[‘uploaded’][$i] are not valid.

Why is that? I need to get these 7 file names and be able to save them on the server. How can I:

1) get an accurate ‘count’ of the number of files? The code above give a count of 5 when I’m uploading 7 files

2) how do I correctly index through the _FILES array in a ‘for’ loop? PHP is telling me the $i values of 0, 1, 2, 3….
are not valid.

(P.S. I am using the input type=”file” multiple=”multiple” name=”uploaded” id=”id_upload” code from the example I saw for enabling multiple file uploads at Retrieving file names out of a multi-file upload control with javascript)

  • 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-27T10:29:37+00:00Added an answer on May 27, 2026 at 10:29 am

    Your name should be array:

    <input type="file" name="uploaded[]" id="id_upload" />
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot retrieve data from Cassandra after I exit the cli. When I go
I'm trying to retrieve data from an SQL Server 2000 server, and place into
I am currently struggling with a query that needs to retrieve multiple records from
I've got a simple PHP image gallery where the PHP reads data from a
I cannot understand the Oracle documentation. :-( Does anybody know how to fetch multiple
I cannot correctly position the div form in my layout. By looking at my
I cannot seem to debug my JavaScript code with Firebug. The play button is
I just come across a strange problem where i cannot retrieve the sql stored
I am trying to clean up my code from memory leaks and I am
On this site each page is made up of multiple .jsp files. There is

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.