Ver Mensaje Individual
  #6 (permalink)  
Antiguo 18/02/2010, 01:49
s3bas7iian
 
Fecha de Ingreso: febrero-2010
Mensajes: 9
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Por favor ayuda con este error...

Aca dejo el cod PHP entero que da problemas.

<?php
include('config.php');
$myconn = conectar();
session_start();
if(isset($_POST['send']))
{
if(is_file($_FILES['userfile']['tmp_name']))
{
if($_FILES['userfile']['size'] > 2000000)
{
$tipos = array('image/jpeg','image/png','image/gif', 'image/x-png');
if(in_array($_FILES['userfile']['type'], $tipos)
{
$q_ins = mysql_query("INSERT INTO `posts` (`id`, `userid`, `comentario`) VALUES (NULL , ". $_SESSION['userid'] .", '" . $_POST['comentario'] . "') ;");
$q_get = mysql_query("SELECT * FROM `posts` WHERE `userid` =" . $_SESSION['userid'] . " ORDER BY `id` DESC LIMIT 1");
$f_get = mysql_fetch_array($q_get);
$a_max = 400;
$src = $_FILES['userfile']['tmp_name'];
$dst = 'image/' . $f_get['id'] . '.jpg';
switch($_FILES['userfile']['type'])
{
case 'image/jpeg':
$img1 = imagecreatefromjpeg($src);
break;
case 'image/png':
$img1 = imagecreatefrompng($src);
break;
case 'image/gif':
$img1 = imagecreatefromgif($src);
break;
default:
$error = 3;
};
$size = getimagesize($_FILES['userfile']['tmp_name']);
$ancho = $size[0];
$alto = $size[1];
$anchoo = $size[0];
$altoo = $size[1];
if($ancho > $a_max)
{
$ratio = $ancho / $a_max;
$ancho = $a_max;
$alto = $a_max / $ratio;
};
if($alto > $a_max)
{
$ratio = $alto / $a_max;
$alto = $a_max;
$ancho = $ancho / $ratio;
};
$img2 = imagecreatetruecolor($ancho, $alto);
imagecopyresampled($img2, $img1, 0, 0, 0, 0, $ancho, $alto, $anchoo, $altoo);
imagejpeg($dst);
if(is_file($dst))
{
$error = 4;
};
} else {
$error = 3;
};
} else {
$error = 2;
};
} else {
$error = 1;
};
};
?>