Ver Mensaje Individual
  #7 (permalink)  
Antiguo 29/12/2010, 16:25
Avatar de Prais
Prais
 
Fecha de Ingreso: octubre-2010
Mensajes: 114
Antigüedad: 13 años, 6 meses
Puntos: 6
Exclamación Respuesta: Este empty me arruina todo el php, alguien sabe algun sinonimo

Ok, de nuevo yo, todavia quebrandome la cabeza. te cuento que probe de dos formas distintas, y las dos estan apunto de salir, pero todavia no lo logro al 100%.

//CON RESPECTO A TU EJEMPLO HICE ESTO EN FILE.PHP :
Código PHP:
Ver original
  1. <?php    
  2. $imagen = "../../../images_inventario/";
  3.  
  4. if (file_exists($imagen)) { ?>    //saque el empty:-)
  5.  
  6. <iframe id="ver" name="ver" src="../../../images_inventario/<?=$IdProducto['DE_IMAGEN'];?>" style="display: block; margin: auto; border-width: 2px; width: 284px;
  7. height: 330px;"></iframe>
  8.  
  9. <? } else { ?>
  10.  
  11. <iframe id="ver" name="ver" src="../../../images_inventario/foto_por_defecto.png" style="display: block; margin: auto; border-width: 2px; width: 284px;
  12. height: 330px;"></iframe>
  13. <? } ?>

//ESTO ES LO QUE CASI CASI RESULTA, YA QUE EN EL LISTADO PRINCIPAL:
//CUANDO HAGO CLICK EN VER LA IMAGEN, TRAE LA IMAGEN ASOCIADA AL PRODUCTO, LA MUESTRA COMO POR 2 SEGUNDOS Y LA CAMBIA POR LA FOTO DE DEFECTO.
//ANALISANDO, ME DOY CUENTA QUE TENGO UNAS FUNCIONES(las cuales controlo el peso, el ancho,etc..) , QUE LLAMAN A PREVISOR.PHP, te las posteo:

*************** TODO ESTE CONTROL ESTA EL FILE.PHP ****************
Código Javascript:
Ver original
  1. function prever() {
  2. var campos = new Array("maxpeso", "maxalto", "maxancho");
  3. for (i = 0, total = campos.length; i < total; i ++)
  4. f.form[campos[i]].disabled = false;
  5. actionActual = f.form.action;
  6. targetActual = f.form.target;
  7. f.form.action = "previsor.php";
  8. f.form.target = "ver";
  9. f.form.submit();
  10. for (i = 0, total = campos.length; i < total; i ++)
  11. f.form[campos[i]].disabled = true;
  12. f.form.action = actionActual;
  13. f.form.target = targetActual;
  14. }
************************************************** **************
Código Javascript:
Ver original
  1. function ini() {
  2.  
  3. document.forms.formu.actualizar = actuar;
  4. window.frames.ver.location.href = "previsor.php";
  5. document.forms.formu.actualizar(0, 0, 0);
  6. }
************************************************** ***************
// Y EN PREVISOR.PHP :
Código PHP:
Ver original
  1. $defecto = "foto_por_defecto.png";
  2. $Ok = isset($_FILES["archivo"]);
  3. $url = ($Ok) ? $_FILES["archivo"]["tmp_name"] : $defecto;
  4. list($anchura, $altura, $tipoImagen, $atributos) = getimagesize($url);
  5. $error = (isset($atributos)) ? 0 : 1;
  6. $los_tipos = array("gif", "jpg", "png");
  7. $tipo = ($Ok) ? "image/".$los_tipos[$tipoImagen - 1] : "image/png";
  8. $fichero = ($Ok && ($error == 0)) ? $_FILES["archivo"]["name"] : $defecto;
  9. $tam = filesize($url);
  10. $OkTam = isset($_POST["maxpeso"]);
  11. $OkAncho = isset($_POST["maxancho"]);
  12. $OkAlto = isset($_POST["maxalto"]);
  13. $maxTam = ($OkTam) ? (int) $_POST["maxpeso"]: 100000;
  14. $maxAncho = ($OkAncho) ? (int) $_POST["maxancho"]: 640;
  15. $maxAlto = ($OkAlto) ? (int) $_POST["maxalto"]: 480;
  16. $error += ($tam <= $maxTam) ? 0 : 2;
  17. $ancho = ($error == 1) ? 0 : $anchura;
  18. $alto = ($error == 1) ? 0 : $altura;
  19. $error += ($ancho <= $maxAncho) ? 0 : 4;
  20. $error += ($alto <= $maxAlto) ? 0 : 8;
  21. $datos = ($error == 0) ? $url : $defecto;
  22. $onload = ($Ok) ? "onload='parent.datosImagen($tam, $ancho, $alto, $error)'": '';
  23. $datos_imagen = fread(fopen($datos, "rb"), filesize($datos));
  24. $_SESSION["cont"] = $datos_imagen;
  25. $_SESSION["tipo"] = ($error == 0) ? $tipo : "image/png";
  26.  
  27. ?>

//CON RESPECTO A UN INTENTO PROPIO HICE ESTO EN FILE.PHP :

Código PHP:
Ver original
  1. <iframe src="previsor.php?<?=$IdProducto['ID_PRODUCTO'];?>" id="ver" name="ver" style="display: block; margin: auto; border-width: 2px; width: 284px; height: 330px;">
  2. </iframe>
// Y EN PREVISOR.PHP :
Código PHP:
Ver original
  1. $id_producto=$_REQUEST['id_producto'];
  2. $Result=mysql_query("select DE_IMAGEN from lk_inv_producto where ID_PRODUCTO='$id_producto'",$cn);
  3. $SqlQuery=mysql_fetch_array($Result);
  4.  
  5. $imagen = "../../../images_inventario/";
  6.  
  7. if (file_exists($imagen)) { //LE VOLVI A SACAR EL EMPTY:-)
  8. $defecto= $SqlQuery['DE_IMAGEN'];
  9. } else {
  10. $defecto = "foto_por_defecto.png";
  11. }
  12.  
  13. $defecto = "$defecto";
  14. $Ok = isset($_FILES["archivo"]);
  15. $url = ($Ok) ? $_FILES["archivo"]["tmp_name"] : $defecto;
  16. list($anchura, $altura, $tipoImagen, $atributos) = getimagesize($url);
  17. $error = (isset($atributos)) ? 0 : 1;
  18. $los_tipos = array("gif", "jpg", "png");
  19. $tipo = ($Ok) ? "image/".$los_tipos[$tipoImagen - 1] : "image/png";
  20. $fichero = ($Ok && ($error == 0)) ? $_FILES["archivo"]["name"] : $defecto;
  21. $tam = filesize($url);
  22. $OkTam = isset($_POST["maxpeso"]);
  23. $OkAncho = isset($_POST["maxancho"]);
  24. $OkAlto = isset($_POST["maxalto"]);
  25. $maxTam = ($OkTam) ? (int) $_POST["maxpeso"]: 100000;
  26. $maxAncho = ($OkAncho) ? (int) $_POST["maxancho"]: 640;
  27. $maxAlto = ($OkAlto) ? (int) $_POST["maxalto"]: 480;
  28. $error += ($tam <= $maxTam) ? 0 : 2;
  29. $ancho = ($error == 1) ? 0 : $anchura;
  30. $alto = ($error == 1) ? 0 : $altura;
  31. $error += ($ancho <= $maxAncho) ? 0 : 4;
  32. $error += ($alto <= $maxAlto) ? 0 : 8;
  33. $datos = ($error == 0) ? $url : $defecto;
  34. $onload = ($Ok) ? "onload='parent.datosImagen($tam, $ancho, $alto,$error)'": '';
  35. $datos_imagen = fread(fopen($datos, "rb"), filesize($datos)); //POR ESTA LINEA ME RECLAMA , CUANDO QUIERO VISUALIZAR LA IMAGEN
  36. $_SESSION["cont"] = $datos_imagen;
  37. $_SESSION["tipo"] = ($error == 0) ? $tipo : "image/png";
  38.  
  39. ?>
************************************************** **************

La pregunta del año, con cual es mas recomendable, y como puedo sacar el detallito..

el archivo del previsor.php, son casi iguales(para que no piensen que me mande todo un codigaso en el posteo), solo le cambie la primera parte al primer ejemplo.

Espero nuevamente tu orientacion, ANTE-MANO GRACIAS.-