Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/12/2010, 19:29
Avatar de Prais
Prais
 
Fecha de Ingreso: octubre-2010
Mensajes: 114
Antigüedad: 13 años, 6 meses
Puntos: 6
Exclamación respuesta:CASI-CASI FUNCIONA Este empty me arruina todo el php.

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 :

<?php
$imagen = "../../../images_inventario/";

if (file_exists($imagen)) { ?> //saque el empty

<iframe id="ver" name="ver" src="../../../images_inventario/<?=$IdProducto['DE_IMAGEN'];?>" style="display: block; margin: auto; border-width: 2px; width: 284px;
height: 330px;"></iframe>

<? } else { ?>

<iframe id="ver" name="ver" src="../../../images_inventario/foto_por_defecto.png" style="display: block; margin: auto; border-width: 2px; width: 284px;
height: 330px;"></iframe>
<? } ?>

//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 ****************
function prever() {
var campos = new Array("maxpeso", "maxalto", "maxancho");
for (i = 0, total = campos.length; i < total; i ++)
f.form[campos[i]].disabled = false;
actionActual = f.form.action;
targetActual = f.form.target;
f.form.action = "previsor.php";
f.form.target = "ver";
f.form.submit();
for (i = 0, total = campos.length; i < total; i ++)
f.form[campos[i]].disabled = true;
f.form.action = actionActual;
f.form.target = targetActual;
}

************************************************** **************
function ini() {

document.forms.formu.actualizar = actuar;
window.frames.ver.location.href = "previsor.php";
document.forms.formu.actualizar(0, 0, 0);
}

************************************************** ***************
// Y EN PREVISOR.PHP :

$defecto = "foto_por_defecto.png";
$Ok = isset($_FILES["archivo"]);
$url = ($Ok) ? $_FILES["archivo"]["tmp_name"] : $defecto;
list($anchura, $altura, $tipoImagen, $atributos) = getimagesize($url);
$error = (isset($atributos)) ? 0 : 1;
$los_tipos = array("gif", "jpg", "png");
$tipo = ($Ok) ? "image/".$los_tipos[$tipoImagen - 1] : "image/png";
$fichero = ($Ok && ($error == 0)) ? $_FILES["archivo"]["name"] : $defecto;
$tam = filesize($url);
$OkTam = isset($_POST["maxpeso"]);
$OkAncho = isset($_POST["maxancho"]);
$OkAlto = isset($_POST["maxalto"]);
$maxTam = ($OkTam) ? (int) $_POST["maxpeso"]: 100000;
$maxAncho = ($OkAncho) ? (int) $_POST["maxancho"]: 640;
$maxAlto = ($OkAlto) ? (int) $_POST["maxalto"]: 480;
$error += ($tam <= $maxTam) ? 0 : 2;
$ancho = ($error == 1) ? 0 : $anchura;
$alto = ($error == 1) ? 0 : $altura;
$error += ($ancho <= $maxAncho) ? 0 : 4;
$error += ($alto <= $maxAlto) ? 0 : 8;
$datos = ($error == 0) ? $url : $defecto;
$onload = ($Ok) ? "onload='parent.datosImagen($tam, $ancho, $alto, $error)'": '';
$datos_imagen = fread(fopen($datos, "rb"), filesize($datos));
$_SESSION["cont"] = $datos_imagen;
$_SESSION["tipo"] = ($error == 0) ? $tipo : "image/png";

?>


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

<iframe src="previsor.php?<?=$IdProducto['ID_PRODUCTO'];?>" id="ver" name="ver" style="display: block; margin: auto; border-width: 2px; width: 284px; height: 330px;">
</iframe>

// Y EN PREVISOR.PHP :

$id_producto=$_REQUEST['id_producto'];
$Result=mysql_query("select DE_IMAGEN from lk_inv_producto where ID_PRODUCTO='$id_producto'",$cn);
$SqlQuery=mysql_fetch_array($Result);

$imagen = "../../../images_inventario/";

if (file_exists($imagen)) { //LE VOLVI A SACAR EL EMPTY
$defecto= $SqlQuery['DE_IMAGEN'];
} else {
$defecto = "foto_por_defecto.png";
}

$defecto = "$defecto";
$Ok = isset($_FILES["archivo"]);
$url = ($Ok) ? $_FILES["archivo"]["tmp_name"] : $defecto;
list($anchura, $altura, $tipoImagen, $atributos) = getimagesize($url);
$error = (isset($atributos)) ? 0 : 1;
$los_tipos = array("gif", "jpg", "png");
$tipo = ($Ok) ? "image/".$los_tipos[$tipoImagen - 1] : "image/png";
$fichero = ($Ok && ($error == 0)) ? $_FILES["archivo"]["name"] : $defecto;
$tam = filesize($url);
$OkTam = isset($_POST["maxpeso"]);
$OkAncho = isset($_POST["maxancho"]);
$OkAlto = isset($_POST["maxalto"]);
$maxTam = ($OkTam) ? (int) $_POST["maxpeso"]: 100000;
$maxAncho = ($OkAncho) ? (int) $_POST["maxancho"]: 640;
$maxAlto = ($OkAlto) ? (int) $_POST["maxalto"]: 480;
$error += ($tam <= $maxTam) ? 0 : 2;
$ancho = ($error == 1) ? 0 : $anchura;
$alto = ($error == 1) ? 0 : $altura;
$error += ($ancho <= $maxAncho) ? 0 : 4;
$error += ($alto <= $maxAlto) ? 0 : 8;
$datos = ($error == 0) ? $url : $defecto;
$onload = ($Ok) ? "onload='parent.datosImagen($tam, $ancho, $alto,$error)'": '';
$datos_imagen = fread(fopen($datos, "rb"), filesize($datos)); //POR ESTA LINEA ME RECLAMA , CUANDO QUIERO VISUALIZAR LA IMAGEN
$_SESSION["cont"] = $datos_imagen;
$_SESSION["tipo"] = ($error == 0) ? $tipo : "image/png";

?>

************************************************** **************

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.-

Última edición por Prais; 29/12/2010 a las 16:16