Wednesday 13 August 2003 12:56:57 am
Hi,
I uploaded it because of Your posting, because there are errorwarnings. Fell free to change it or please upload yours, when it is working.
Part from http://pear.php.net/package-info.php?package=HTTP_Upload
// This software is licensed by the LGPL
// -> http://www.gnu.org/copyleft/lesser.txt // (c) 2001 by Tomas Von Veschler Cox
/**
* Sets the name of the destination file
*
* @param string $mode A valid mode: 'uniq', 'safe' or 'real' or a file name
* @param string $prepend A string to prepend to the name
* @param string $append A string to append to the name
*
* @return string The modified name of the destination file
* @access public
*/
function setName($mode, $prepend=null, $append=null)
{
switch ($mode) {
case 'uniq':
$name = $this->nameToUniq();
$this->upload['ext'] = $this->nameToSafe($this->upload['ext'], 10);
$name .= '.' . $this->upload['ext'];
break;
case 'safe':
$name = $this->nameToSafe($this->upload['real']);
if (($pos = strrpos($name, '.')) !== false) {
$this->upload['ext'] = substr($name, $pos + 1);
} else {
$this->upload['ext'] = '';
}
break;
case 'real':
$name = $this->upload['real'];
break;
default:
$name = $mode;
}
$this->upload['name'] = $prepend . $name . $append;
$this->mode_name_selected = true;
return $this->upload['name']; }
/**
* Unique file names in the form: 9022210413b75410c28bef.html
* @see HTTP_Upload_File::setName()
*/
function nameToUniq()
{
if (! $this->_seeded) {
srand((double) microtime() * 1000000);
$this->_seeded = 1;
}
$uniq = uniqid(rand());
return $uniq; }
/**
* Format a file name to be safe
*
* @param string $file The string file name
* @param int $maxlen Maximun permited string lenght
* @return string Formatted file name
* @see HTTP_Upload_File::setName()
*/
function nameToSafe($name, $maxlen=250)
{
$noalpha = 'áéíóúàèìòùäëïöüÁÉÍÓÚÀÈÌÒÙÄËÏÖÜâêîôûÂÊÎÔÛñçÇ@';
$alpha = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncCa';
$name = substr ($name, 0, $maxlen);
$name = strtr ($name, $noalpha, $alpha);
// not permitted chars are replaced with "_"
return ereg_replace ('[^a-zA-Z0-9,._\+\()\-]', '_', $name); } Greetings, ekke
http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing
|