denoteone Posted May 6, 2008 Share Posted May 6, 2008 I am trying to create a page that you can select files on a server using check boxes. on submit it passes the values of the boxes checked as an array and then creates a zipped file from that array and mails is . This is my first time working with array's in PHP so i was hopping for some help. My code so far <form action="ZipNSend.php" method="post"> <input type="checkbox" value="fileOne.pdf"/>File number One <input type="checkbox" value="fileTwo.pdf"/>File number Two <input type="checkbox" value="fileThree.pdf"/>File number Three </form> Now i need for ZipNSend.php to take what ever values were checked and create an array out of them. this is were I am stuck... can anyone help me get started or point me in the right direction? Thanks Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/ Share on other sites More sharing options...
p2grace Posted May 6, 2008 Share Posted May 6, 2008 Pass the actual input as an array <form action="ZipNSend.php" method="post"> <input type="checkbox" name="files[]" value="fileOne.pdf"/>File number One <input type="checkbox" name="files[]" value="fileTwo.pdf"/>File number Two <input type="checkbox" name="files[]" value="fileThree.pdf"/>File number Three </form> when you grab the post variable it'll already be an array Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534677 Share on other sites More sharing options...
denoteone Posted May 6, 2008 Author Share Posted May 6, 2008 so to test the array it would look something like this? code] <? $myArray = array($_POST['filename']; print_r($myArray); ?> Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534684 Share on other sites More sharing options...
p2grace Posted May 6, 2008 Share Posted May 6, 2008 Test like this: <?php $arr = $_POST['files']; print_r($arr); ?> Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534686 Share on other sites More sharing options...
denoteone Posted May 6, 2008 Author Share Posted May 6, 2008 so this zip.lib.php library that I found says all I have to do is pass the array and it will out put the zip file. the value that I am passing in the form will be the path to the file on the server. so my array might look like (pdfs/fileOne.pdf, pdfs/fileTwo.pdf, pdfs/fileThree.pdfs <?php $arr = $_POST['files']; include("zip.lib.php"); $ziper = new zipfile(); $ziper->addFiles($arr); //array of files $ziper->output("myzip.zip"); ?> so would that work? Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534695 Share on other sites More sharing options...
p2grace Posted May 6, 2008 Share Posted May 6, 2008 Theoretically yes Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534696 Share on other sites More sharing options...
denoteone Posted May 6, 2008 Author Share Posted May 6, 2008 Thanks p2grace you have been a lot of help. I will let you know how it turns out. Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-534697 Share on other sites More sharing options...
denoteone Posted May 7, 2008 Author Share Posted May 7, 2008 Ok I am so close. the zip file named myzip.zip is getting sent via an attachment mail message. but when the email gets there is says that it is 900kbs but when I save and open it is not showing anything? I check the server and the file is created and there? Does anybody have an idea why this might be happening? ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/104452-array-from-check-boxes/#findComment-535267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.