Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file manipulation

Status
Not open for further replies.

manicleek

Technical User
Jun 16, 2004
143
GB
Can anyone tell me how I can display a list of files in a folder on my server and when clicked have them deleted?
 
I would write a script that, when given no input, displays the directory. My script would use opendir() to open the directory, and readdir() to output those directories. It would output them as links in the form of "<a href=" from directory>">Name from directory</a>".

If the script finds an element "filename" in $_GET, it would then delete that entry using unlink().

Handling subdirectories might be tricky. You might want the script to move to that subdirectory and display its contents rather than delete it.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
on my delete file page I have the script:

Code:
if(file_exists($file)) {
unlink($file);
echo "file $file deleted";
} else {
echo "no such file";
}

which works but I have to have the delete script in the same directory as what I'm trying to delete, if I want the delete file in another directory, how do I specify a path?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top