Ver Mensaje Individual
  #7 (permalink)  
Antiguo 02/06/2009, 09:21
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Adaptacion de imagenes

No mi sugerencia es que crees un

Código:
<form name="addPict" action="resize.php" method="post" enctype="multipart/form-data">
  <input type="hidden" name="MAX_FILE_SIZE" value="2048000">
  <input type="file" name="srcImg" size="60">
</form>

Luego cuando des submit en el php haces un codigo algo similar

resize.php
Código PHP:
<?php
include("class_resize.php");

foreach(
$_REQUEST as $key => $value){
    $
$key $value;
}
foreach(
$_FILES as $key => $value){
    foreach(
$value as $key2 => $value2){
        
//echo $key2 . " - " . $value2."<br />";
        
if($key2 == "name"){
            
$srcImg $value2;
        }
        if(
$key2 == "tmp_name"){
            
$srcImg_tmp $value2;
        }
        if(
$key2 == "type"){
            
$srcImg_type $value2;
        }
    }
}


if(isset(
$_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']> 2048000){
    
$action 'index.php?error=Upload FAILED, file is too large!';
    
header("Location: $action");
    die();
}

$txtname strtolower(basename($srcImg));
$getExplName explode("."$txtname);
$txtname $_COOKIE["ID_Cookie"] . "." $getExplName[1];

$result = @move_uploaded_file($srcImg_tmp$txtname);

$imgTrans = new imageTransform();
$imgTrans->sourceFile $txtname;
$imgTrans->targetFile "directorio/".$txtname;
$imgTrans->resizeToHeight 200;
//Puedes tambien modificar el width
//$imgTrans->resizeToWidth = 200;
$imgTrans->resize();

@
unlink($txtname);
?>