Tema: imagen
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/04/2010, 20:37
garrablanka
 
Fecha de Ingreso: abril-2010
Mensajes: 68
Antigüedad: 14 años
Puntos: 0
Pregunta imagen

buenas noches segun Chile, como andan??
miren encontre esto en la web para subir imagenes a la web:

<?php
$postback = (isset($_POST['enviar'])) ? true:false;
if ($postback) {
error_reporting(E_ALL);
define("ALTURA", 100);
define("NAMETHUMB", "c:/windows/tmp/thumbtemp");
define ("DBHOST", "localhost");
define("DBNAME", "upload");
define("DBUSER", "root");
define("DBPASSWORD", "");

$mimetypes = array("image/jpeg", "image/pjpeg", "image/gif", "image/png");
$name = $_FILES["foto"]["name"];
$type = $_FILES["foto"]["type"];
$tmp_name = $_FILES["foto"]["tmp_name"];
$size = $_FILES["foto"]["size"];

if(!in_array($type, $mimetypes)) die ("El archivo que subiste no es una imagen valida.");

switch($type) {
case $mimetypes[0]:
case $mimetypes[1]:
$img = imagecreatefromjpeg($tmp_name);
break;
case $mimetypes[2]:
$img = imagecreatefromgif($tmp_name);
break;
$img = imagecreatefrompng($tmp_name);
break;
}
$datos = getimagesize($tmp_name);
$ratio = ($datos[1]/ALTURA);
$ancho = round($datos[0]/$ratio);
$thumb = imagecreatetruecolor($ancho, ALTURA);
imagecopyresized($thumb, $img, 0, 0, 0, 0, $ancho, ALTURA, $datos[0], $datos[1]);

switch($type) {
case $mimetypes[0]:
case $mimetypes[1]:
imagejpeg($thumb, NAMETHUMB);
break;
case $mimetypes[2]:
imagegif($thumb, NAMETHUMB);
break;
case $mimetypes[3]:
imagepng($thumb, NAMETHUMB);
break;
}

$fp = fopen($tmp_name, "rb");
$tfoto = fread($fp, filesize($tmp_name));
$tfoto = addslashes($tfoto);
fclose($fp);

@unlink($tmp_name);
@unlink(NAMETHUMB);

$nombre = $_POST["nombre"];
$link = mysql_connect(DBHOST, DBUSER, DBPASSWORD) or die (mysql_error($link));;
mysql_select_db(DBNAME, $link) or die (mysql_error($link));
$sql = "INSERT INTO tabla(nombre, foto, thumb, mime) VALUES ('$nombre', '$tfoto', '$tthumb', '$type')";
mysql_query($sql, $link) or die (mysql_error($link));
echo "Fotos guardadas";
exit();
} else {echo"chupaloo";}
?>


me sube las imagenes muuyy bien el problema que tengo es que no las puedo mostrar, tengo esto pero no me funciona.. ¬¬

<img src="verblob.php?idfoto=1&tam=1" alt="Imagen desde Blob" />
<?php

$idfoto= (isset($_GET["idfoto"])) ? $_GET["idfoto"] :exit();
$tam = (isset($_GET["tam"])) ? $_GET["tam"] : 1;
switch($tam) {
case "1": $campo = "foto"; break;
case "2": $campo = "thumb"; break;
default: $campo = "foto"; break;
}
$sql = "SELECT foto FROM tabla WHERE idfoto= $idfoto";
$link = mysql_connect("localhost", "admin", "shupalo96") or die (mysql_error($link));;
mysql_select_db("upload", $link) or die (mysql_error($link));
$conn= mysql_query($sql, $link) or die (mysql_error($link));
$datos = mysql_fetch_array($conn);

$imagen= $datos[0];
$mime = $datos[1];
header("Content-Type: image/jpeg");
echo $imagen;
?>

que hago??
gracias por la pacienciaa
saludos :P