Comunidad de diseño web y desarrollo en internet online

PHP - Redimensionar imagen

Citar            
MensajeEscrito el 12 Jun 2008 01:28 pm
hola como va?. Estoy acomodando un codigo, lo estoy acomodando a mis necesidades. El problema es q no se como hacer para digamos... darle el nombre d la imagen o la direccion del archivo temporal con la variable global funcion $_FILE
bueno les paso el codigo

Código :

<?PHP
if($_GET['tipo']=="subir-img"){
include("config.php") ;
$inpt="flog_f";
$ruta=$_FILES[$inpt]['name'];
$max=500;

if(empty($max)) $max = 150; // Esta parte me la dijo omega ya q no se me ocurrio poner un default xD
if(eregi('gif$',$ruta,$ext) || eregi('jpg$',$ruta,$ext) || eregi('png$',$ruta,$ext)) {
if($ext[0] == "jpg") $ext[0] = "jpeg";
$funcion  = 'imagecreatefrom'.$ext[0];
$fuente   = @$funcion($ruta);
$imgAncho = imagesx($fuente);
$imgAlto  = imagesy($fuente);
if($imgAncho>$imgAlto) {
    $ancho = $max;
    $alto = intval(($imgAlto/$imgAncho)*$max);
}
else {
    $ancho = intval(($imgAncho/$imgAlto)*$max);
    $alto = $max;
}
$nnew=date("d"."m"."y"."h"."i"."s").".jpg";
$imagen = imagecreatetruecolor($ancho,$alto);
imagecopyresized($imagen,$fuente,0,0,0,0,$ancho,$alto,$imgAncho,$imgAlto);
imagejpeg($imagen,"upload/".$nnew); 
$thumb=imagecreatetruecolor(120,138);
imagecopyresampled($thumb,$imagen,0,0,0,0,120,130,$ancho,$alto);
imagejpeg($thumb,"upload/chica/chica-".$nnew);
$numero2 = count($_POST); $tags2 = array_keys($_POST); $valores2 = array_values($_POST);
for($i=0;$i<$numero2;$i++){ $$tags2[$i]=$valores2[$i]; }
mysql_query("INSERT INTO ggaleria (idseccion,img,fecha,chica) VALUES ('$seccion','upload/".$nnew."','$fecha','upload/chica/chica-".$nnew."')") ;
echo"SUBIDA";
}
else {
header("Content-type: image/gif");
$imagen = imagecreate(400,100);
$bg     = imagecolorallocate($imagen,255,255,255);
$color  = imagecolorallocate($imagen,0,0,0);

imagestring($imagen,"3",5,0,"Error: No se puede generar la imagen.",$color);
imagestring($imagen,"3",5,15,"       Verifique la ruta o el formato",$color);
imagestring($imagen,"3",5,30,"       Formatos aceptables: Gif, Jpg y Png",$color);

imagegif($imagen);
imagedestroy($imagen);
}
}
?>
<div id=""></div>
<div id="">
<form action="upload.php?tipo=subir-img" method="post" enctype="multipart/form-data" name="flog_form">
<br />Subir una imagen a la galeria.<br /><br />
Seccion *
<input type="text" name="seccion" maxlength="100" size="20"><br /><br />
Archivo *<input  name="flog_f" type="file" id="flog_f" size="9"><br /><br /><br />
<input name="button" type="submit" value="Subir" class="BOTON">
</form>
</div>


gracias y saludos

Por nehuen

43 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 12 Jun 2008 09:55 pm
No lei el código, pero usa este código donde recibas la imagen y te enseñara como esta formado la matriz $_FILES.

Código :

echo "<pre>";
print_r($_FILES);
echo "</pre>";


saludos

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.