Ver Mensaje Individual
  #12 (permalink)  
Antiguo 10/09/2003, 00:12
Avatar de davidMS
davidMS
 
Fecha de Ingreso: abril-2003
Ubicación: Chepe
Mensajes: 202
Antigüedad: 21 años
Puntos: 0
este es el archivo que pide la clase para el control de errores:

Código PHP:
<?PHP

    $ERR
["UNABLE_TO_OUTPUT"]        = "Unable to output: ";
    
$ERR["FILE_DOESNOT_EXSIT"]        = "This file does not exist: ";
    
$ERR["FUNCTION_DOESNOT_EXIST"]    = "This function does not exist: ";
    
$ERR["GD2_NOT_CREATED"]            =    "GD2 is installed, function ImageCreateTruecolor() exists, but image is not created";
    
$ERR["IMG_NOT_CREATED"]            =    "Image is not created ImageCreate(). {GD2 suppor is OFF}";
    
$ERR["GD2_UNAVALABLE"]            =    "You specified to use GD2, but not all GD2 functions are present.";
    
$ERR["GD2_NOT_RESIZED"]            =    "GD2 is installed, function ImageCopyResampled() exists, but image is not resized";
    
$ERR["IMG_NOT_RESIZED"]            =    "Image was not resized. {GD2 suppor is OFF}";
    
$ERR["UNKNOWN_OUTPUT_FORMAT"]    =    "This image format cannot bu output: ";
    
$ERR["NO_IMAGE_FOR_OUTPUT"]        =    "Image you are trying to output does not exist. ";
    
$ERR["IMG_NOT_SUPPORTED"]        =    "Can not create image. Sorry, this image type is not supported yet.";
?>

y esta es la funcion para llamar a la clase:

Código PHP:
function getjpg ($nombre,$imagen,$url)
{
    
//variables globales
    
global $tabla,$donde,$db;
    
//    
    //jala extencion del archivo (string)
    
function getFileExtension($str
    {
        
$i strrpos($str,".");
        if (!
$i) { return ""; }
        
$l strlen($str) - $i;
        
$ext substr($str,$i+1,$l);
        return 
$ext;
    }
    
//**//    
    //Chequea que el archivo sea un jpg o jpeg
    
$pext getFileExtension($nombre);
    
$pext strtolower($pext);
    if ((
$pext != "jpg")  && ($pext != "jpeg"))
    {
        print 
"<h1>ERROR</h1>Extension de imagen no compatible!!<br>";
        print 
"<p>Por favor solo use imagenes con extension .jpg o .jpeg<br><br>";
        print 
"El archivo que usted intento subir tenia la extension: <b>$pext</b></p>\n";
        exit();
    }
    
//ahora a cambiar el tamaño de la imagen
        
require("inc/hft_image.php"); /*aqui es donde esta la clase*/ 
    //se define ancho y largo deseado
        
$destination_width 250
        
$destination_height 132;
    
//**//
     
        
$image = new hft_image($imagen); 
        
$image->resize("*"$destination_width'-'); 
        
$image->output_resized($url"JPEG"); 
    
// terminado el resize borramos el archivo temporal       
        
unlink($imagen);
    
//ahora si, insertamos el nombre del archivo en la bd//
        
mysql_db_query ($db,'insert into '.$tabla.' ('.$donde.') values ("'.$url.'")') or die 
        (
'<div align="center"><font color="#FF0000" size="2"><strong>Error al procesar a la BD, intentelo despues!.
        </strong></font> </div></body>'
        
);