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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:41:27+00:00 2026-06-02T08:41:27+00:00

i have a upload script to upload some files to a directory. every file

  • 0

i have a upload script to upload some files to a directory. every file runs through a loop and will be checked if there are errors with the size or ending or even not. in case of no error it will be uploaded.

if (is_array($_FILES ['image'] ['tmp_name'])) {
    foreach ( $_FILES ['image'] ['tmp_name'] as $key => $val ) {
        ...

        if (! in_array ( $fileExt, $allowedExtensions )) {
            $errors [$fileName] [] = "format not accepted";
        }...

            if ((count ( $errors1 ) == 0) && (count ( $errors ) === 0))  {
               if (move_uploaded_file ( $fileTemp, $fileDst )) {
                //...                               
            }
        }   
     }
}

my question is, is there a way to count the number of the uploaded files that successfully ran through that loop? thanks a lot.

  • 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-02T08:41:29+00:00Added an answer on June 2, 2026 at 8:41 am

    You need to count each successful upload.

    like below:

       if (is_array($_FILES ['image'] ['tmp_name'])) {
        $Counter=0;     // initialize counter variable
            foreach ( $_FILES ['image'] ['tmp_name'] as $key => $val ) {
    
                $fileName = $_FILES ['image'] ['name'] [$key];
                $fileSize = $_FILES ['image'] ['size'] [$key];
                $fileTemp = $_FILES ['image'] ['tmp_name'] [$key];
    
                $fileExt = pathinfo ( $fileName, PATHINFO_EXTENSION );
                $fileExt = strtolower ( $fileExt );
    
                if (empty ( $fileName ))
                continue;
    
                if (! in_array ( $fileExt, $allowedExtensions )) {
                    $errors [$fileName] [] = "format not accepted";
                }...
    
                    if ((count ( $errors1 ) == 0) && (count ( $errors ) === 0))  {
                       if (move_uploaded_file ( $fileTemp, $fileDst )) {
                        //...           
                       $Counter++;       // increment if successful upload
                    }
                }   
             }
        }
    
    echo $Counter;  //it will give total count of successfully uploaded files
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a script that will upload files to a general uploads folder,
I have a bash script to upload some files to my webserver. The problem
I have a file upload script which will be available to the general public
I have an upload script that write a index.html file, I modified it to
So I have an upload script, and I want to check the file type
I'm writing a php file upload script for a project - I have seen
I have a question. I have a script that handles file upload, and after
I have a csv file that I will be regularly updating through a batch
For some reason, we have a script that creates batch files to XCOPY our
So I have my upload script working just fine, but now it's a matter

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.