Re: Re: HTTP_Upload unique files

From: Date: Sun, 03 Oct 2004 09:54:53 +0000
Subject: Re: Re: HTTP_Upload unique files
References: 1 2 3 4 5 6 7 8  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-33625@lists.php.net to get a copy of this message
Ammar Ibrahim wrote:
Thanks Norbert for your suggestions, very helpful :) ...
I suggest you to do the following: 1. Create a new member variable in the class HTTP_Upload_File. You also have to store prepend & append string that get passed to setName(): var $mode_name_seq = false; var $mode_name_seq_prepend = null; var $mode_name_seq_append = null;
This would pollute the package with anopther 3 variables, wouldn't an array be better. var $mode_name_seq['flag'] = false; //this flag should hold if the user wants a 'seq' naming mode, a different key for the array would be more useful :) var $mode_name_seq['prepend'] var $mode_name_seq['append']
You don't want to define them with null. Else, you will trigger type conversion notices. Rather intiate with '' (single quotes). As to variables, I doubt you really could polute the package with them. However, I do agree that since these are a group of variables, you could create an array. Else, and this would probably make more sense, simply pass the array as an argument to setName(). You could also use constants so that you wouldn't have to pass anything, and it would keep the class clean.
3. Create the function _nameToSeq() which will be called from moveTo() function _nameToSeq($path) { // $path contains your path // file name to rename is in $this->upload['name'] // // don't forget to include $this->mode_name_seq_prepend // and $this->mode_name_seq_prepend // // return $yourfinalname; .. }
Though the name _nameToSeq() is much better, because this is a utility function. I prefer to use nameToSeq(). So that it matches the current naming convention for a similiar function nameToUniq(). Or change both functions and add '_' at the beginning
I don't see why you guys keep wanting to prefix with an underscore. Underscores mark private/protected methods and properties in php4 and private properties and methods in php5. They should not be used on methods that are public. Klaus

« previous php.pear.dev (#33625) next »