kev wood Posted May 20, 2008 Share Posted May 20, 2008 i have found this code but would like someone who has used this before to tell me if it will do what i want it to. i do not want to go deleting everything on the server just the contents of one file. the code i have found is as follows. <? $mydir = "/path/to/dir/"; $d = dir($mydir); while($entry = $d->read()) { if ($entry!= "." && $entry!= "..") { unlink($entry); } } $d->close(); rmdir($mydir); ?> Link to comment https://forums.phpfreaks.com/topic/106470-delete-contents-of-file-on-server/ Share on other sites More sharing options...
bilis_money Posted May 20, 2008 Share Posted May 20, 2008 i don't think that will delete the content of a file. do you want to delete the partial contents of the file? or all of its contents? if so my advice it delete the file then replace it with blank one but the same name. Link to comment https://forums.phpfreaks.com/topic/106470-delete-contents-of-file-on-server/#findComment-545736 Share on other sites More sharing options...
kev wood Posted May 20, 2008 Author Share Posted May 20, 2008 that sounds like the better option. Link to comment https://forums.phpfreaks.com/topic/106470-delete-contents-of-file-on-server/#findComment-545751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.