Código:
if(isset($_POST["MAX_FILE_SIZE"])){ // Obtenemos la información de la imagen $im_info = getimagesize($_FILES['userfile']['tmp_name']); $name_file = $_FILES['userfile']['name']; //nombre del archivo $nombre = rand (1,100)."-".$name_file; // Evaluamos si es GIF(1) o JPEG(2) // y creamos la imagen en GD switch($im_info[2]) { case 1: $imagen = imagecreatefromgif($_FILES['userfile'] ['tmp_name']); break; case 2: $imagen = imagecreatefromjpeg($_FILES['userfile'] ['tmp_name']); break; } ini_set('upload_max_filesize','30M'); //seteo el tamaño maximo permitido por defecto en php.ini, solo para este PHP ini_set('memory_limit','9500M');//cambio limite de memoria ini_set('post_max_size','200M');//cambio tamaño maximo set_time_limit(0);// pongo infinito en el tiempo que tarde en cargarse // Definimos la medida máxima $th_max = 117; // de la muestra (thumbnail) $det_max = 308; // de la imagen detalle // Evaluamos si la imagen es horizontal if($im_info[0]>$im_info[1]) { // Definimos las medidas de las imagenes $th_w = $th_max; $th_h = ($im_info[1]/$im_info[0])*$th_max; $det_w = $det_max; $det_h = ($im_info[1]/$im_info[0])*$det_max; } else { $th_w = ($im_info[0]/$im_info[1])*$th_max; $th_h = $th_max; $det_w = ($im_info[0]/$im_info[1])*$det_max; $det_h = $det_max; } // Creamos las imágenes $thumb = imagecreatetruecolor($th_w,$th_h); $detalle = imagecreatetruecolor($det_w,$det_h); // Copiamos la original escalada imagecopyresampled($thumb,$imagen,0,0,0,0, $th_w,$th_h,imagesx($imagen),imagesy($imagen)); imagecopyresampled($detalle,$imagen,0,0,0,0, $det_w,$det_h,imagesx($imagen),imagesy($imagen)); // Destruimos la imagen original imagedestroy($imagen); // Damos salida a nuestros archivos imagejpeg($thumb,'../img/tapas/th_'.$nombre,60); imagejpeg($detalle,'../img/tapas/'.$nombre,60); // Destruimos las imagenes temporales imagedestroy($thumb); imagedestroy($detalle); }