[PHP-DEV] Delete checked files
Hi everybody, I show a list of files that I upload to the user's folder using the next code: $path= ../clients/$user; $dir = opendir ($root); while ($archivo = readdir ($dir)) { $size = filesize($path/$filename); $size = ($size/1024); $size = intval($size * 100 ) / 100; if ($filename!= . $filename!=..) { echo trtda href='$path/$filename'$filename/a/tdtd$size Kb/td/tr; } } I want to add a checkbox in every file i get in the user's folder. My question is: Is there any way to use some kind of function to delete selected files? I am not sure if i can use javascript to evaluate which is checked and how. And after that evaluation, how to call a unlink ($filename) to delete the files. Any help would be greatly appreciated. Nau -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] delete checked files
Why not start an html form element before u start outputting the tr /s and td /s of ur table. Finish it at the end of ur while loop, oh...and include a submit button. The submit calls either a new script or the same script itself, only using url query strings to specify a different part of the code. Each input type=checkbox should be NAMED with the filename of each file it is representing. Or possibly with a small identifier to differentiate between the file reference and the input name, say c_ at the front. And perhaps you ought to remove the file-extention. So if your directory contained mydoc.doc, the checkbox would be named c_mydoc Then u use a while loop exactly the same as in the code u pasted to the list, but instead of using the filename as a string that you then echo to the screen, you simply strip off the file extension and add c_ at the beginning. You will now be referring to each of the chechbox form elements. Simply while-loop your way through the form elements (each identified by the file in the directory so you will know when/if an element exists because you will still be looping through the opendir() command, or not), asking it if it is checked or not and delete it if ($c_mydoc){ unlink ($regular_filename_WITH_extension_and_WITHOUT_c_) } -- Dave Cranwell Torchbox Ltd [EMAIL PROTECTED] tel: (+44) 1608 811 870 mob: (+44) 7760 438 708 http://www.torchbox.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Delete checked files
PHP-DEV is for the development OF PHP, not for developing WITH PHP. Ask support questions on PHP-GENERAL ([EMAIL PROTECTED]). Sander On 2002.02.25 17:04 Nautilis wrote: Hi everybody, I show a list of files that I upload to the user's folder using the next code: $path= ../clients/$user; $dir = opendir ($root); while ($archivo = readdir ($dir)) { $size = filesize($path/$filename); $size = ($size/1024); $size = intval($size * 100 ) / 100; if ($filename!= . $filename!=..) { echo trtda href='$path/$filename'$filename/a/tdtd$size Kb/td/tr; } } I want to add a checkbox in every file i get in the user's folder. My question is: Is there any way to use some kind of function to delete selected files? I am not sure if i can use javascript to evaluate which is checked and how. And after that evaluation, how to call a unlink ($filename) to delete the files. Any help would be greatly appreciated. Nau -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Delete checked files
Ups! I am very sorry. As i am a newbie at php i thought, as you suggested, that this was for developement with php. Thx alot anyway - Original Message - From: Sander Roobol [EMAIL PROTECTED] To: Nautilis [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, February 25, 2002 5:38 PM Subject: Re: [PHP-DEV] Delete checked files PHP-DEV is for the development OF PHP, not for developing WITH PHP. Ask support questions on PHP-GENERAL ([EMAIL PROTECTED]). Sander On 2002.02.25 17:04 Nautilis wrote: Hi everybody, I show a list of files that I upload to the user's folder using the next code: $path= ../clients/$user; $dir = opendir ($root); while ($archivo = readdir ($dir)) { $size = filesize($path/$filename); $size = ($size/1024); $size = intval($size * 100 ) / 100; if ($filename!= . $filename!=..) { echo trtda href='$path/$filename'$filename/a/tdtd$size Kb/td/tr; } } I want to add a checkbox in every file i get in the user's folder. My question is: Is there any way to use some kind of function to delete selected files? I am not sure if i can use javascript to evaluate which is checked and how. And after that evaluation, how to call a unlink ($filename) to delete the files. Any help would be greatly appreciated. Nau -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php