Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/12/2005, 03:47
Avatar de Keleriano
Keleriano
 
Fecha de Ingreso: junio-2002
Ubicación: Granada
Mensajes: 133
Antigüedad: 21 años, 10 meses
Puntos: 0
Yo uso la siguiente función.

Código PHP:

function Subir($var$ruta$nombre$maxtamanio) {
   
$ok false;
   
$tipo $_FILES[$var]["type"];
   if(
$tipo=="image/jpeg" || $tipo=="image/pjpeg") {
     
$name  $_FILES[$var]["name"];
     
$array explode("."$name);
     
$nr    count($array);
     
$ext   $array[$nr-1];
     if(
$ext=="jpg" || $ext=="jpeg") {
       
$ok true;
     }
   }
  
   if(isset(
$maxtamanio)) {
     if(
$_FILES[$var]["size"] > $maxtamanio) {
       
$ok false;
     }
   }
  
   if(
$ok==true) {
     
$tempname $_FILES[$var]['tmp_name'];
     if(isset(
$nombre)) {
       
$uploadpath $ruta.$nombre;
     } else {
       
$uploadpath $ruta.$_FILES[$var]['name'];
     }
     if(
is_uploaded_file($_FILES[$var]['tmp_name'])) { 
       while(
move_uploaded_file($tempname$uploadpath)) {
         echo 
'Subiendo...';
       }
     }
     return 
$uploadpath;
   } else {
     return 
false;
   }
  }