asi:
Código HTML:
<body> <form name="form1" method="post" action="dofoto.php"> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <th scope="col"><div align="left"><img src="regpic.gif" width="131" height="136" alt=""></div></th> </tr> <tr> <td><input name="imagen" type="file" id="imagen"></td> </tr> <tr> <td><input type="submit" name="Submit" value="grabar foto"></td> </tr> </table> </form> </body>
en el dofoto.php
Código PHP:
<?php
session_start();
$id = $_SESSION['id_user'];
$nombre = $_SESSION['nombre'];
$apellido = $_SESSION['apellido'];
include("../conexion.php");
if(isset($_POST['Submit']) && !empty($_POST['Submit'])){
$name = basename($_FILES['imagen']['name']);
$t_name = $_FILES['imagen']['tmp_name'];
$dir = 'upload/';
$status = "";
if ($name == "" or $t_name == "")
echo "<script language='JavaScript'>alert('Debe Elegir una Imagen!');</script>";
else{
$ancho = 130;
$info = pathinfo($name);
$tamano = getimagesize($t_name);
$width = $tamano[0];
$height = $tamano[1];
if ($width > $ancho){
//check shape
if ($width == $height){$opc=1;}
if ($width >$height){$opc=2;}
if ($width< $height){$opc=3;}
switch($opc){
case 1:
$ancho= 130;
$alto = 130;
break;
case 3:
$alto = 130;
$ratio = $alto/$height;
$ancho = intval($width*$ratio);
echo $ancho;
echo $alto;
break;
case 2:
$ancho = 130;
$ratio = $ancho/$width;
$alto = intval($height*$ratio);
break;
}
if ($info['extension']== "jpg" || "jpeg" || "JPG"){
$nuevaimagen = imagecreatetruecolor($ancho,$alto);
$viejaimagen = imagecreatefromjpeg($t_name);
imagecopyresized($nuevaimagen,$viejaimagen,0,0,0,0,$ancho,$alto,$width,$height);
$original = "upload/".$name;
$dir = "upload/".$name;
copy($t_name,$original);
imagejpeg($nuevaimagen,$original);
}
}
else
echo "<script language='JavaScript'>alert('La Imagen debe ser mayor de 400 px de ancho');</script>";
}
}
?>
Me aparece Notice: Undefine Index image on line 11 y 12.
no entiendo la razon.
gracias por cualquier ayuda