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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:28:50+00:00 2026-06-10T02:28:50+00:00

How do I link the file input type with the checkbox? This is what

  • 0

How do I link the file input type with the checkbox?

This is what I have so far:

<input type="file" name="file_upload[0]"  /> <input type="checkbox" name="checkbox[0]"> checkbox 1 <br />
<input type="file" name="file_upload[1]"  /> <input type="checkbox" name="checkbox[1]"> checkbox 2 <br />
<input type="file" name="file_upload[2]"  /> <input type="checkbox" name="checkbox[2]"> checkbox 3 <br />
<input type="file" name="file_upload[3]"  /> <input type="checkbox" name="checkbox[3]"> checkbox 4 <br />

Now I need to check in PHP when a file is uploaded the correspondent checkbox is checked (preferably with a loop), but I can’t make it work.

This is what I have in PHP:

if (isset($_FILES['file_upload[1]']) && isset($_FILES['checkbox[1]']))  {
    //do something
} else {
    //do something else
}
  • 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-10T02:28:52+00:00Added an answer on June 10, 2026 at 2:28 am

    You need to change your checkbox input tag to <input type="checkbox" name="checkbox[3]" value="1" >

    i.e. you need to add missing value="" attribute

    and as mentioned in the comment

    you need to check if(isset($_POST['checkbox'][0])) { instead in $_FILES

    Try printing both print_r($_FILES) and print_r($_POST) … this should give you idea of what structure of data you are receiving after submitting

    You can just loop through the file_uploaded array and then check if related checbox index is set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In CakePHP view, When I try this code <?php echo $form->input('download_link', array('type'=>file)); ?>> whose
Here is my HTML code: <div id=playlist_item> <ul class=link id=link> <div class=style><input type=checkbox class=styled>
I have an HTML, PHP - Jquery form. The last input is a file
I have an html upload <input type=file id=myfile/> . When I click it, it
I pasted the code given in this link to a file called md5.js. http://www.webtoolkit.info/javascript-md5.html
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this
I am able to generate a link using my file upload system, now after
I have some jQuery code. I have called an Ajax function file, file.php, that
I have a VBScript copied from the link http://www.robvanderwoude.com/vbstech_ui_password.php In the existing VBSscript I
I've a simple form that send data to a php file, this file updates

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.