jagguy Posted December 7, 2006 Share Posted December 7, 2006 I want to read in a directory of filenames, and decide which files to delete by going through the filenames.The problem is I forget how to read in a dir(I am sure I could do it a while ago) and when deleting on winxp home with ulink() I always get permission denied. Link to comment https://forums.phpfreaks.com/topic/29755-delete-files/ Share on other sites More sharing options...
willfitch Posted December 7, 2006 Share Posted December 7, 2006 Here is an example of opening the temp directory and reading all sessions:[code=php:0]<?php$session_dir = '../Tmp';$handle = opendir($session_dir);while (($file = readdir($handle)) != false) { if (ereg("^sess", $file)) { $fhandle = file($session_dir.'/'.$file); printf("<pre>%s</pre>",print_r($fhandle[0],1)); }}?>[/code]Also, I think you mean unlink(). Link to comment https://forums.phpfreaks.com/topic/29755-delete-files/#findComment-136616 Share on other sites More sharing options...
matto Posted December 7, 2006 Share Posted December 7, 2006 You will get a permission denied error on *nix if the user the server is running as (sometimes known as 'nobody') doesn't own or belong to the group for the file you are attempting to delete.Hope this helps... ;) Link to comment https://forums.phpfreaks.com/topic/29755-delete-files/#findComment-136655 Share on other sites More sharing options...
jagguy Posted December 7, 2006 Author Share Posted December 7, 2006 hi,i have winxp home so i think your talking about unix type.I have no idea how to set the permissions for this, as it seems to be OK already. Link to comment https://forums.phpfreaks.com/topic/29755-delete-files/#findComment-136778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.