Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    checkboxes, submit values, and other stuff

    ok, still working with firepages code. I am new with PHP so I need alot of help. Ok, basically what I am doing is making a whole lot of files for download, and the user decides which files they want by checking the check boxes next to the names. Then with the code given, the files will be added to one zip file and downloaded. How do I create the checkboxes, and create a submit button that then zips the file, and either starts the download automatically, or create a link on a new page?

    This is basically whats happening, the zip file automatically creates itself with the preset files (file.txt).

    (entire code with functions here: http://www.firepages.org/public/zipfile.php.txt)


    <?php

    $zipfile = new zipfile();

    // add the subdirectory ... important!
    $zipfile -> add_dir("dir/");

    // add the binary data stored in the string 'filedata'
    $filedata = implode("",file("searchtest.php"));
    $zipfile -> add_file($filedata, "dir/file.txt");

    // OR instead of doing that, you can write out the file to the local disk like this:
    $filename = "youre_selected_files.zip";
    $fd = fopen ($filename, "wb");
    $out = fwrite ($fd, $zipfile -> file());
    fclose ($fd);

    //the next three lines force an immediate download of the zip file:
    //header("Content-type: application/octet-stream");
    //header("Content-disposition: attachment; filename=youre_selected_files.zip");
    //echo $zipfile -> file();

    // then offer it to the user to download:
    echo "<a href=\"youre_selected_files.zip\">Click here to download the new zip file.</a> ";


    ?>

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well what you could do is take the file names submitted by the form and either store them in the files.txt file you mentioned or pass them along.

    Put the coding for the zip file into a function and then pass those file names along to it or read them from the files.txt.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Registered User
    Join Date
    Jul 2002
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have no idea how to do that... Is there anyway I could put an if statement with each checkbox, adding the file if its checked, hit a submit button and the file is created? If so what would be the code for that?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •