Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/12/2010, 21:18
Avatar de Prais
Prais
 
Fecha de Ingreso: octubre-2010
Mensajes: 114
Antigüedad: 13 años, 6 meses
Puntos: 6
Exclamación A solo un error para que funcione... el visualizador de imagen..

Hola foro, si de nuevo yo,, bueno les comento, reduci varios errores quedandome uno solo, no lo postie en el otro posteo, porque ya cambiaron varias cosas y como comente estoy a solo un error, les posteo:

En previsor.php:
Código PHP:
Ver original
  1. $id_producto=$_REQUEST['ID_PRODUCTO'];  //RESCATO EL ID, PARA HACER LA CONSULTA
  2. $Result=mysql_query("select DE_IMAGEN from lk_inv_producto where ID_PRODUCTO='$id_producto'",$cn);  // BUSCO AL PRODUCTO
  3. $SqlQuery=mysql_fetch_array($Result);
  4.  
  5.  if ($SqlQuery['DE_IMAGEN']== 'N/I'){   //AKA SI LA IMAGEN CONSULTADA TRAE DE LA CONSULTA 'N/I'(NO INFORMADO), $imagen TOMA EL VALOR DE LA FOTO POR DEFECTO.
  6. $imagen = "KG_00_SinFotoProducto.png";
  7. } else {
  8. $imagen= $SqlQuery['DE_IMAGEN'];  //SINO $imagen TOMA EL VALOR QUE LE TRAIGA EL $SqlQuery['DE_IMAGEN'];
  9.   }  
  10.     $defecto = $imagen;  //AKA LE PASO EL VALOR DE $imagen, A $defecto
  11.     $Ok = isset($_FILES["archivo"]);
  12.     $url = ($Ok) ? $_FILES["archivo"]["tmp_name"] : $defecto;
  13.     list($anchura, $altura, $tipoImagen, $atributos) = getimagesize($url);
  14.     $error = (isset($atributos)) ? 0 : 1;
  15.     $los_tipos = array("gif", "jpg", "png");
  16.     $tipo = ($Ok) ? "image/".$los_tipos[$tipoImagen - 1] : "image/png";
  17.     $fichero = ($Ok && ($error == 0)) ? $_FILES["archivo"]["name"] : $defecto;
  18.     $tam = filesize($url);
  19.     $OkTam = isset($_POST["maxpeso"]);
  20.     $OkAncho = isset($_POST["maxancho"]);
  21.     $OkAlto = isset($_POST["maxalto"]);
  22.     $maxTam = ($OkTam) ? (int) $_POST["maxpeso"]: 100000;
  23.     $maxAncho = ($OkAncho) ? (int) $_POST["maxancho"]: 640;
  24.     $maxAlto = ($OkAlto) ? (int) $_POST["maxalto"]: 480;
  25.     $error += ($tam <= $maxTam) ? 0 : 2;
  26.     $ancho = ($error == 1) ? 0 : $anchura;
  27.     $alto = ($error == 1) ? 0 : $altura;
  28.     $error += ($ancho <= $maxAncho) ? 0 : 4;
  29.     $error += ($alto <= $maxAlto) ? 0 : 8;
  30.     $datos = ($error == 0) ? $url : $defecto;
  31.     $onload = ($Ok) ? "onload='parent.datosImagen($tam, $ancho, $alto, $error)'": '';
  32.     $datos_imagen = fread(fopen($datos, "rb"), filesize($datos));  // EN ESTA LINEA ARROJA EL ERROR.- Warning: fread(): supplied argument is not a valid stream resource
  33.     $_SESSION["cont"] = $datos_imagen;
  34.     $_SESSION["tipo"] = ($error == 0) ? $tipo : "image/png";
  35.  
  36. ?>
  37. <html >
  38. <head>
  39. <style type="text/css" >
  40. html    {
  41.     height: 100%;
  42. }
  43. body    {
  44.     height: 100%;
  45.     overflow: hidden;
  46.     background-color: #eeeeee;
  47.     background-image: url(previendo.php?dato=<?=$fichero;$imagen;?>);  //AKA LE ENVIA LOS DATOS A PREVIENDO.
  48.     background-repeat: no-repeat;
  49.     background-position: center center;
  50. }
  51. </style>
  52. </head>
  53. <body <?=$onload;?>>
  54.  
  55. </body>
  56. </html>

y en previendo.php:
Código PHP:
Ver original
  1. $url = ($_SESSION["cont"] == "")
  2.  
  3. ? fread(fopen("$imagen", "rb"), filesize("$imagen"))  // AKA DESEO PASARLE LA IMAGEN QUE SE DEFINIO EN PREVISOR.PHP
  4.     : $_SESSION["cont"];
  5. $tip = ($_SESSION["tipo"] == "")
  6.     ? "image/png"
  7.     : $_SESSION["tipo"];
  8. header("Content-type: $tip");
  9. echo $url;

// el error dice asi:

Warning: fread(): supplied argument is not a valid stream resource in C:\xampp\htdocs\proyecto\inventario\previsor.php on line 32

........Alguien sabe por que ?