networkthis Posted June 7, 2008 Share Posted June 7, 2008 I am trying to accomplish the following, but am having a hard time figuring out where to go with it. I have a file directory which displays all the files in the directory and displays all relevent info about the file on the page allowing the user to delete the file or save the file. However I would like to use a checkbox and select multiples to be deleted at the same time. Any ideas? Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 7, 2008 Share Posted June 7, 2008 make the checkboxes an array and make the values the file names. Then when the page is submitted iterrate through the array and delete the files in the array. Sample code Form: file1.jpg <input type="checkbox" name="fileDelete[]" value="file1.jpg"><br> file2.jpg <input type="checkbox" name="fileDelete[]" value="file2.jpg"><br> file3.jpg <input type="checkbox" name="fileDelete[]" value="file3.jpg"><br> Processing Page: <?php if (count($_POST['fileDelete'])) { foreach ($_POST['fileDelete'] as $file) { //Delete the file } } ?> Of course you are going to want to implement some good validation else someone might maliciously delete any files on the server by submitting custom forms. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.