Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/03/2009, 10:45
futbolregional
 
Fecha de Ingreso: agosto-2008
Mensajes: 71
Antigüedad: 15 años, 8 meses
Puntos: 2
Problema al subir imagenes al Servidor

Buenas, tengo un formulario de envio en el que subo imagenes al servidor, el problema que me encuentro es que no se como poner un max de envio en el tamaño de la imagen, y por otro lado, a la hora de enviar la foto, da igual el tamaño que tenga, siempre se envia con el tamaño que le indicio en $foto_max.
Alguien podria ayudarme??

$tipMime=array("image/jpge","image/pjpeg","image/gif","image/png");
$name=$_FILES['Imagen']['name'];
$type=$_FILES['Imagen']['type'];
$size=$_FILES['Imagen']['size'];
$tmp_name=$_FILES['Imagen']['tmp_name'];
$error=$_FILES['Imagen']['error'];
$archivoTemp=getimagesize($_FILES['Imagen']['tmp_name']);

if(!in_array($type,$tipMime)){
$mensajeImagen="El archivo <strong>$name</strong> no sirve o no se subió ninguna imagen.";
}else{
switch($type){
case $tipMime[0]:
$imagen=imagecreatefromjpeg($tmp_name);
break;
case $tipMime[1]:
$imagen=imagecreatefromjpeg($tmp_name);
break;
case $tipMime[2]:
$imagen=imagecreatefromgif($tmp_name);
break;
case $tipMime[3]:
$imagen=imagecreatefrompng($tmp_name);
break;
}//switch
$foto_max=200;
if($archivoTemp[0]>$archivoTemp[1]){
$foto_width=$foto_max;
$foto_height=round(($archivoTemp[1]/$archivoTemp[0])*$foto_max);
}else{
$foto_width=round(($archivoTemp[0]/$archivoTemp[1])*$foto_max);
$foto_height=$foto_max;
}
$foto=imagecreatetruecolor($foto_width,$foto_heigh t);
imagecopyresampled($foto,$imagen,0,0,0,0,$foto_wid th,$foto_height,imagesx($imagen),imagesy($imagen)) ;
imagedestroy($imagen);
$carpetafoto="../../img/articulos/";

switch($type){
case $tipMime[0]:
imagejpeg($foto,$carpetafoto.$name);
break;
case $tipMime[1]:
imagejpeg($foto,$carpetafoto.$name);
break;
case $tipMime[2]:
imagegif($foto,$carpetafoto.$name);
break;
case $tipMime[3]:
imagepng($foto,$carpetafoto.$name);
break;
}

$fotoFinal='img/articulos/'.$name;
imagedestroy($foto);
unlink($_FILES['Imagen']['tmp_name']);
}