Re: Re: HTTP_Upload unique files
| From: | Didier Galland | Date: | Mon, 04 Oct 2004 15:46:36 +0000 |
| Subject: | Re: Re: HTTP_Upload unique files | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33650@lists.php.net to get a copy of this message | ||
Ammar Ibrahim wrote:
Why not ? I think it's up to the developper to know what files sequence he wants to use ? It would be far more simple and flexible, and a default scheme could be provided. In this case, the dedicated job of the upload object would be to search the pattern and increment it. Searching with $sequence_number= sscanf($this->pattern,%d);//in a loop where $this->pattern is %d is the sequence number // or in a while loop with $filenametocheck=sprintf($this->pattern,$i);//like Norbert suggested.Return false if there is no match. Setting a name with sprintf($this->pattern,$i) The two (getting/setting) in a while loop like the one Norbert suggested. It's just ideas, don't know if it's could be done. Regards. DidierAdding more control to files naming is a real need ! Thanks to Ammar. As the goal is to give more control, we can go further. For the sequence / naming schema, i think it would be nice to let the user (of the package) decide by setting/getting a class property "pattern" e.g. $file->pattern='userGuide[%d].pdf'; or $file->pattern='userGuide_%d.pdf'; and/or after $last_seq = _get_last_sequence('newpattern%d.pdf').Yeah Didier! that should be VERY useful. brilliant. but i'm not sure how it works? I think you'd need place holders, because you don't know the names previously.
so we define two place holders, 1) userfile_basename 2) userfile_ext e.g: {userfile_basename}[%d].{userfile_ext}, {userfile_basename}_%d.{userfile_ext} this is a better way to specify a pattern, since the names are arbitrary Ammar Ibrahim