943,630 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 20861
  • PHP RSS
Apr 2nd, 2005
0

How can i delete unused and unneeded images from a folder using php ?

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Decency is offline Offline
22 posts
since Aug 2004
Apr 2nd, 2005
0

Re: How can i delete unused and unneeded images from a folder using php ?

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.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 3rd, 2005
0

Re: How can i delete unused and unneeded images from a folder using php ?

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Decency is offline Offline
22 posts
since Aug 2004
Apr 3rd, 2005
0

Re: How can i delete unused and unneeded images from a folder using php ?

Quote originally posted by Decency ...
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?
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Apr 4th, 2005
1

Re: How can i delete unused and unneeded images from a folder using php ?

To remove a directory:

rmdir('directory_name');
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 4th, 2005
0

Re: How can i delete unused and unneeded images from a folder using php ?

yeah its the same but sometimes the delete() function does not work on certain systems so you will need to use unlink() or unset()
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Decency is offline Offline
22 posts
since Aug 2004
Apr 5th, 2005
0

Re: How can i delete unused and unneeded images from a folder using php ?

I think you need the right file system permissions.
Team Colleague
Reputation Points: 53
Solved Threads: 5
PHP/vBulletin Guru
Gary King is offline Offline
360 posts
since Nov 2003
Apr 28th, 2010
0
Re: How can i delete unused and unneeded images from a folder using php ?
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);
?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
charvie is offline Offline
24 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Php Repeat Query Automatically
Next Thread in PHP Forum Timeline: join two tables from different databases





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC