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

  • Home
  • SEARCH
  • 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 6968631
In Process

The Archive Base Latest Questions

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

I have a script where users can upload multiple files (max. 8). The HTML

  • 0

I have a script where users can upload multiple files (max. 8). The HTML is generated by a piece of PHP:

$max_no_img=8;  
for($i=1; $i<=$max_no_img; $i++){
    <div class='photo photo$i'>
        <div class='new_label'>
        Foto $i:
        </div>
        <div class='new_input'>
        <input type='file' name='images[]' />
        </div>
    </div>";
}

So the array images[] consists of 8 values. However, every time a user submit it’s form, the form is generating an Array of 8 items and by so, inserting 8 values in the database (whether they are empty or not).

So I would like to unset the empty values, copy the files to my folders and insert the link into my database. But here is the part where the errors happen.

The array of $_FILES consists of 4 things. name, tmp_name, error and size. How do I get it so a complete item (let’s say images[0]) will be unset from the array so I can continue with the items which actually carry a value.

I tried this, but with no results…

unset($_FILES['images'][0])

and

unset($_FILES['images']['name'][0])
unset($_FILES['images']['tmp_name'][0])
unset($_FILES['images']['error'][0])
unset($_FILES['images']['size'][0])

Any advice how to unset a value from a $_FILES-arry?

  • 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-27T16:28:37+00:00Added an answer on May 27, 2026 at 4:28 pm

    You can just ignore them instead of processing or unsetting any items:

    if (!empty($_FILES['images'])) {
        for ($i = 0; $i < count($_FILES['images']['name']); $i++) {
            if (empty($_FILES['images']['name'][$i])) {
                // This item is empty
                echo "Item $i references an empty field.\n";
                continue;
            }
    
            echo "Item $i is a valid file.\n";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want any php script which can demonstrate me how to upload multiple files
I have PHP page where users can upload photos (using Ajax & PHP script).
I have PHP page where users can upload photos (using Ajax & PHP script).
I have an application where users can upload video files of any size, and
On my site I have a page where users can upload files to go
I have a script that allows only authorised users to upload files to a
I have php script that creates a temporary watermark image for users that are
I have a file upload script that works [finally] but want to have users
I have a pretty straight forward uploadified page that allows users to upload files,
I'm writing a php file upload script for a project - I have seen

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.