conozco345
07-18-2002, 06:29 AM
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> ";
?>
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> ";
?>