in reply to uploading a file with the same name

Thank you all for your suggestions! I used amphiplex's suggestion, with a small alteration:
$num=""; while(-e "$Data/$category/$num$imagename"){ $num++; } $imagename = $num.$imagename;
That works great (although the other suggestions would have worked just as well, but I believe in KISS!) I'll have a look at merlyn's column once my brain has stopped being jelly-like...

Replies are listed 'Best First'.
Re: Re: uploading a file with the same name
by amphiplex (Monk) on Jul 24, 2002 at 14:25 UTC
    Nice to hear that :), even though my answer was partly wrong (not the code, I hope, but the part about yours checking for foo0)

    ---- amphiplex
Re: Re: uploading a file with the same name
by shotgunefx (Parson) on Jul 29, 2002 at 08:06 UTC
    One thing to look out for is that if you are expecting lots of images and usage , most 'NIXs do linear scans of directories, meaning that with a lot of images, it can get very, very slow. If you ever used Cache::FileCache you might notice the way it uses digests of the names (for fairly random distribution) and splits the storage into sub-directories. /dir/a/ab/abcd/abcdefghijk.gif

    If you don't expect that kind of usage, I would just go the simple route. You can always modify it later. (Though if people are linking to this stuff, you might want to think about it now.)

    -Lee

    "To be civilized is to deny one's nature."