Re: Multiple file delete
| From: | John Nichel | Date: | Fri, 11 Mar 2005 20:47:09 +0000 |
| Subject: | Re: Multiple file delete | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210551@lists.php.net to get a copy of this message | ||
Ashley M. Kirchner wrote:
I have a page that displays the contents of a folder. Right now, each file has a little 'delete' button next to it that users can click on, however with many files it gets cumbersome. I need to be able to have them click on checkboxes and then hit one delete button which will then get rid of everything checked, but I don't know how to combine the form with PHP so that it takes the info from one into the other and delete what's needed. Any pointers would be very helpful. Thanks. -- APage 1 : <form action="page2.php" method="post"> <input type="checkbox" name="delete[]" value="file1name" />....<br /> <input type="checkbox" name="delete[]" value="file2name" />....<br /> <input type="checkbox" name="delete[]" value="file3name" />....<br /> <!-- More HTML --> Page 2 : <?php $size = sizeof ( $_POST['delete'] ); for ( $i = 0; $i < $size; $i++ ) {
unlink ( $_POST['delete'][$i] );} ?> -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com