Re: Re: HTTP_Upload unique files
| From: | Norbert Mocsnik | Date: | Sun, 03 Oct 2004 23:00:08 +0000 |
| Subject: | Re: Re: HTTP_Upload unique files | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33643@lists.php.net to get a copy of this message | ||
Erik Heerlein wrote:
What about being able to specify the starting number of the sequence? To start at something other than zero? Or pick where the number would go in the filename? Like suppose somebody wanted to do 'userGuide_6.pdf' or userGuide[f][6].pdf. I don't know if there would be a great need to do this I'm just wondering.function nameToSeq($path, $template = '') { .. if (empty($template)) {
$template = $this->upload['name'] . '[%d]';} while (...) { // or do .. while, dunno how you want it
$i++;
$filenametocheck = sprintf($template, $i);
... check if available ...
}
..
}
// usually
$this->$nameToSeq('/upload_path/');
// Erik's suggestion
$this->$nameToSeq('/upload_path/', 'userGuide[f][%d]');
--
Regards,
Norbert Mocsnik
http://norbert.mocsnik.hu/