Jump to content

Array from check boxes


denoteone

Recommended Posts

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

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

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?

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?

 

??? ??? ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.