Hi all
i need to know if there is by a way by any chance to delete unused images from my virtual directory or wwwroot folder dunamically on the user request using php ?
thank you all

Yes this should be possible. There may be some scripts already written to do this although I am not aware of them. You could try searches on google and yahoo to see what you can find. If you don't find anything useful, you will find most of the php functions you will need here.

thank you for such a wonderful reference you gave me
i checked it out and found the way to delete files and folders
and it was just so simple lol

for your reference the code is as this :

<?php

unlink("filename");

?>

can it be more simple ?
lol

thank you for such a wonderful reference you gave me
i checked it out and found the way to delete files and folders
and it was just so simple lol

for your reference the code is as this :

<?php

unlink("filename");

?>

can it be more simple ?
lol

is that the same for deleting folders too?

To remove a directory:

rmdir('directory_name');

commented: very much helpful!! +1

yeah its the same but sometimes the delete() function does not work on certain systems so you will need to use unlink() or unset()

I think you need the right file system permissions.

it would be better to check 1st if the file is in the directory ^^
i got this from the php manual :)
hope it helps you as well
<?php
if(file_exists($file))
unlink($file);
?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.