snorkytheweasel
Thread Starter
- Joined
- May 3, 2006
- Messages
- 215
I have a PHP program that prints (to screen) a list of all of the files in a directory on the web server.
I can't figure out how to add the ability to select a file (or files, if possible) from the list - and delete - the selected file(s). My limited skillset tells me that the selection process is a client-side procedure, but everything else is done with server-side procedures.
And that's where I get stuck.
Any guidance will be greatly appreciated.
Here's what is already working:
<?php
// skip the already-working voodoo code that builds the variable $dirb
// skip the already-working voodoo code that builds the variable $entryb
$d = opendir($dirb); // open the specified directory
while (false !== ($entry = readdir())) // Read directory, one file at a time
{
echo($entryb . "<BR />"); // display the files, one per line
} // end while loop
closedir($d); // Close directory
?>
Here's where I need help:
/* modify code to add a delete button ??? */
echo($entryb . " <BUTTON type='submit'>DELETE</BUTTON><BR />");
/* add a function to delete selected $entryb ??? */
function(deleteit)
{
if(somecondition)
{
authenticate();
unlink($entryb);
}
}
/* add a function to provide some some security ??? */
function(authenticate)
{
// get and test password before allowing file deletion
}
I can't figure out how to add the ability to select a file (or files, if possible) from the list - and delete - the selected file(s). My limited skillset tells me that the selection process is a client-side procedure, but everything else is done with server-side procedures.
And that's where I get stuck.
Any guidance will be greatly appreciated.
Here's what is already working:
<?php
// skip the already-working voodoo code that builds the variable $dirb
// skip the already-working voodoo code that builds the variable $entryb
$d = opendir($dirb); // open the specified directory
while (false !== ($entry = readdir())) // Read directory, one file at a time
{
echo($entryb . "<BR />"); // display the files, one per line
} // end while loop
closedir($d); // Close directory
?>
Here's where I need help:
/* modify code to add a delete button ??? */
echo($entryb . " <BUTTON type='submit'>DELETE</BUTTON><BR />");
/* add a function to delete selected $entryb ??? */
function(deleteit)
{
if(somecondition)
{
authenticate();
unlink($entryb);
}
}
/* add a function to provide some some security ??? */
function(authenticate)
{
// get and test password before allowing file deletion
}