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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:39:33+00:00 2026-05-13T09:39:33+00:00

I have the following form: <form action=download.php method=get> <input type=checkbox name=file1 /> File1 <br/>

  • 0

I have the following form:

<form action="download.php" method="get">
<input type="checkbox" name="file1" /> File1 <br/>
<input type="checkbox" name="file2" /> File2 <br/>
<input type="checkbox" name="file3" /> File3 <br/>
<input type="checkbox" name="file4" /> File4 <br/>
<input type="checkbox" name="file5" /> File5 <br/>

<input type="submit" name="mysubmit" value="Download!">   
</form> 

I cant then GET the ticked value:

<?php echo $_GET["file1"]; ?>

Gives the result: on

However want I want to be able to do is select those options, and each option relates to a PHP file, on Submit each file is combiled into a ZIP

Any help appreciated.

  • 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-13T09:39:33+00:00Added an answer on May 13, 2026 at 9:39 am

    First, add a value field to your form fields and change them to an array:

    <form action="download.php" method="get">
    <input type="checkbox" name="file[0]" value="1" /> File1 <br/>
    <input type="checkbox" name="file[1]" value="1" /> File2 <br/>
    <input type="checkbox" name="file[2]" value="1" /> File3 <br/>
    <input type="checkbox" name="file[3]" value="1" /> File4 <br/>
    <input type="checkbox" name="file[4]" value="1" /> File5 <br/>
    <input type="submit" name="mysubmit" value="Download!">   
    </form> 
    

    Next, in download.php:

    if (!empty($_POST['file'])) {
        // open zip
        $zip_path = '/path/to/created/download.zip';
        $zip = new ZipArchive(); 
        if ($zip->open($zip_path, ZIPARCHIVE::CREATE) !== TRUE) {
            die ("An error occurred creating your ZIP file.");
        }  
        // checkbox values dont matter because only checked boxes show up in POST data
        foreach ($_POST['file'] as $key => $val) {
            // generate filename to add to zip
            $filename = '/path/to/php/file' . $key . '.php';
            $zip->addFile($filename) or die ("ERROR: Could not add the file $filename");  
        }
        $zip->close();
    
        //===============
        // force download
        //===============
    // assume you have a full path to file stored in $zip_path
    if (!is_file($zip_path)) {
      die('The file appears to be invalid.');
    }
    
    $zip_path = str_replace('\\', '/', realpath($zip_path));
    $filesize = filesize($zip_path);
    $filename = substr(strrchr('/'.$zip_path, '/'), 1);
    $extension = strtolower(substr(strrchr($zip_path, '.'), 1));
    
    // use this unless you want to find the mime type based on extension
    $mime = array('application/octet-stream');
    
    header('Content-Type: '.$mime);
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: '.sprintf('%d', $filesize));
    header('Expires: 0');
    
    // check for IE only headers
    if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))) {
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
    } else {
      header('Pragma: no-cache');
    }
    
    $handle = fopen($filepath, 'rb');
    fpassthru($handle);
    fclose($handle);
    
    
    } // close $_POST check
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 260k
  • Answers 260k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yourmanage.py is referencing an application (notifications). This forces Django to… May 13, 2026 at 11:24 am
  • Editorial Team
    Editorial Team added an answer Set WindowStyle to None, and ResizeMode to NoResize (either in… May 13, 2026 at 11:24 am
  • Editorial Team
    Editorial Team added an answer Most of the questions you're asking about depends mostly on… May 13, 2026 at 11:24 am

Related Questions

I have the following form <form id=enter_email method=post action=> <input type=text value=enter email />
I have the following form: <% form_for(:tag, :url => {:action => post_tag, :id =>
Original title: Can't fixed misconfigured routes I want to make a search based in
I have the following HTML form: <div id=main> <form Id=search-form action=/ViewRecord/AllRecord method=post> <div> <fieldset>
I have the following simple form: <% form_for(@weight) do |f| %> <%= f.error_messages %>

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.