tambien puedes usar una classe,
 
fichero: index.php  
 Código PHP:
    <html>
 
    <head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <meta name="generator" content="Maguma Studio Profesional">
        <title>Upload usando una classe</title>
    </head>
 
    <body bgcolor="#ffffff">
        <p></p>
        <div align="center">
            <form action="func_upload.inc.php" method="post" name="FormUpImg" enctype="multipart/form-data">
                <div align="center">
                    <input name="userfile" type="file" size="40">
        <br><br>
                    <input name="boton_up" type="submit" value="Aceptar y Enviar">
                    <input name="send" type="hidden" value="ok">
                    </div>
            </form>
        </div>
    </body>
 
</html> 
    
  
------------------- 
fichero: func_upload.inc.php  
 Código PHP:
    <?php
 
include("class.upload.inc.php");// cargamos classe de upload
 
 
if ( $send == "ok" && $_FILES[userfile]['name'] ){// del formulario sacamos el boton ok, comienza la classe upload
 
        $upload = new upload();
 
        if ($upload -> putFile ("userfile")) {
 
            $imagen = $upload->file_name;
 
        }
    }
echo "ya tienes copiada la imagen <b>".$imagen;
 
?>    
   
------------------- 
fichero: class.upload.inc.php  
 Código PHP:
    <?php
 
class UpLoad
{
    var $archivos_permitidos;    
    var $dir;        
    var $max_filesize;        
    var $idioma;    
    var $error = 0;
    var $file_type;
    var $file_name;
    var $file_size;
    var $archivo;
    var $file_path;
    var $warning = 0;
 
    function UpLoad ($permiso="" , $max_file = 25000, $dir = "images",$idioma = "spanish"){//el 25000, son 25k max.upload, y images es la carpeta, modifica a tu gusto
        if ( empty ($permiso) ) $permiso = array ("image/pjpeg","image/x-png","image/jpeg","image/png","image/gif");//pueden subir, png, jpg, o gif
        $this->archivo_permitido = $permiso; 
        $this->max_filesize = $max_file;
        $this->dir = $dir;
        $this->idioma = $idioma;
    }
    
    function putFile ($file){
        $this->file_type = strtok ( $_FILES[$file]['type'], ";"); 
        $this->file_name = $_FILES[$file]['name']; 
        $this->file_size = $_FILES[$file]['size']; 
        $this->temp = $_FILES[$file]['tmp_name'];  // upload para o diretorio temp
        
        if(!in_array($this->file_type, $this->archivo_permitido))
            $this->Error(1);
        
        if ( ($this->file_size <= 0) || ($this->file_size > $this->max_filesize) ) $this->Error(2);
        
        if ($this->error == ""){
            $filename = basename ($this->file_name); 
            if (!empty ($this->dir) ) 
                $this->arquivo = $this->dir."/".$filename;
            else 
                $this->arquivo = $filename; 
 
            if (file_exists($this->arquivo)){
 
                srand((double)microtime()*1000000);
                $filename = rand(0,20000)."_".$filename;
 
                $new_letras = "";
                $leng_letras = 8;
                for ($i=1; $i<=$leng_letras; $i++)
                
                    {
 
                    $abcdario = chr(rand(97,122));
                    $new_letras .= $abcdario;
                }
                
                $filename = "copia_".$new_letras."_".$filename;
                
                if (!empty ($this->dir)) 
                    $this->arquivo = $this->dir."/".$filename;
                else 
                    $this->arquivo = $filename;
            }
            
            if(!is_uploaded_file($this->temp)) $this->Error(3);
            if(!@move_uploaded_file($this->temp,$this->arquivo) ) $this->Error(4);
            
            return $this->arquivo;
        }
        else {
            return false;
        }
 
    }
 
    function Error($op){
        if($this->idioma="spanish"){
            switch ($op){
                case 0: return; break;
                case 1: $this->error = "Error 1: Error tipo de archivo no permitido, jpg , gif , png: $this->file_type."; break;
                case 2: $this->error = "Error 2: Error en el tamaño de fichero: $this->file_size Kb. Tamaño Maximo $this->max_filesize."; break;
                case 3: $this->error = "Error 3: Error de transferencia de datos: $this->file_name."; break;
                case 4: $this->error = "Error 4: Error cuando se copia el fichero al directorio temporal $this->temp para $this->file_name."; break;
                case 5: $this->error = "Error 5: Error gd.dll, no esta instalada"; break;
            }
        }
 
           ?> <SCRIPT> alert("<?= $this->error; ?>"); </SCRIPT>
 
            <script languaje="javascript">
                setTimeout ("history.back()", 1);
            </script>
 
            <?php
       exit;
    }
}
?>    
  
----------------------------------- 
luego ya es cosa de modificar, incluir y adaptar a tus necesidades  
 
 