Reply to Re: How do you delete a zip file from a directory?

Your name:

Reply:


Posted by Tim Roberts on 10/12/06 05:48

"comp.lang.php" <phillip.s.powell@gmail.com> wrote:

>
>petersprc@gmail.com wrote:
>> To expand a wildcard pattern, try the glob function. unlink isn't able
>> to handle wildcards. For instance:
>>
>> $zips = glob("$theDir/*.zip");
>> if ($zips === false) {
>> die("glob failed.");
>> }
>> foreach ($zips as $zip) {
>> unlink($zip) or die("unlink failed.");
>> }
>
>Thanx but how efficient is that? You could be looping through a
>directory potentially containing thousands of images within my
>application each time you display a list of them

You shouldn't worry too much about efficiency until you try it. Try doing
an "ls *.zip" from a command line; the "glob" is going to take roughly the
same time. The Unix directory APIs are pretty efficient.

On the other hand, once you get into "thousands" of images, you might
consider some clever subdirectories. I have a client that stores PDF and
JPG files, where the names have the form 'p12345.pdf'. I use mod_rewrite
to change that to a directory tree p1/23/p12345.pdf. That way, there are
no more than 100 files per directory.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация