how can i make a php file list all files in directory but with features like this I need a Display of each file like this Example: Displayed Filename1 - filesize - (Rename Button) (Delete File button) Displayed Filename2 - filesize - (Rename Button) (Delete File button) Displayed Filename3 - filesize - (Rename Button) (Delete File button) Displayed Filename4 - filesize - (Rename Button) (Delete File button) Displayed Filename5 - filesize - (Rename Button) (Delete File button) And it keeps going is this possible they have things like this in website hosts they have a page where you can manage files
Read all files into an array, then loop through it, use each item as filename and pass it to filesize(). That's the basic stuff. Then create links next to each file, and use the unlink() function to delete files. Or rename() to rename it. This should get you started. Give it a try and show us what you've tried if you get stuck at some point.
Ok heres where i am so far but delete doesnt work <b>FileName</b> - <b> File Size </b> <br> <br> <?php foreach (glob("*.php") as $filename) { echo "$filename size " . filesize($filename) . " <a href="unlink($filename);">Delete</a> <br> \n"; } ?> PHP: This is the Output: FileName - File Size ban.php size 357 Delete banlist.php size 357 Delete clearlog.php size 1675 Delete config.php size 32 Delete download.php size 515 Delete download1.php size 83 Delete index.php size 1029 Delete log.php size 1902 Delete mailto.php size 310 Delete test.php size 222 Delete testing.php size 1838 Delete The Delete button links look like this: http://cynscriptz.com/demo/dlscript/unlink(ban.php); http://cynscriptz.com/demo/dlscript/unlink(banlist.php); http://cynscriptz.com/demo/dlscript/unlink(clearlog.php); and goes on like this but the links dont work why not
You have to pass the filename to a new or the same page, and THEN delete it. Eg: "<a href=\"file.php?filename={$filename}\">Delete</a>" // And in the other or same file: if (isset($_GET['filename'])) { unlink($_GET['filename']); } PHP: ... this is just an example. It's not secure for public use.
Ok now it works the way you made it but i tried to add a javascript promt but now it doesnt work ? <b>FileName</b> - <b> File Size </b> <br> <br> <?php foreach (glob("*.php") as $filename) { echo "$filename size " . filesize($filename) . "<a href=\"deletefile.php?filename={$filename}\" onClick="javascript:return confirm('Are you Sure you want to delete File')">Delete File</a><br>"; } ?> PHP: