diff --git a/.gitignore b/.gitignore index 4e4a072..0e827d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ nbproject tmp/* .DS_Store +/img.data/ \ No newline at end of file diff --git a/Imagen.php b/Imagen.php index 50cf725..2df80ab 100644 --- a/Imagen.php +++ b/Imagen.php @@ -134,7 +134,7 @@ class Imagen { { $zebra = new Zebra_Image(); $zebra->source_path = $this->archivoSubido; - $this->archivoComprimido = $id . "." . $this->extension; + $this->archivoComprimido = $this->dirData . "/" . $id . "." . $this->extension; $zebra->target_path = $this->archivoComprimido; $zebra->jpeg_quality = 100; @@ -169,8 +169,8 @@ class Imagen { } return false; } else { - // - //unlink($this->archivoSubido); + //Borra el archivo subido + unlink($this->archivoSubido); return true; } } diff --git a/Mantenimiento.php b/Mantenimiento.php index e72bd57..9f5d833 100644 --- a/Mantenimiento.php +++ b/Mantenimiento.php @@ -302,6 +302,14 @@ class Mantenimiento { } $this->datosURL['opc'] = 'inicial'; $this->datosURL['id'] = null; + //Comprueba si existe la imagen en datos para borrarla. + $extensiones = array ("png", "gif", "jpg"); + foreach ($extensiones as $extension) { + $archivo = "img.data/" . $id . "." . $extension; + if (file_exists($archivo)) { + unlink ($archivo); + } + } $url = $this->montaURL(); header('Location: ' . $url); return; @@ -345,17 +353,18 @@ class Mantenimiento { } $valor = $_POST[$campo] == "on" ? '1' : $valor; } else { - if (stristr("imagen", $this->campos[$campo]['Type'])) { + if (stristr($this->campos[$campo]['Type'], "imagen")) { //procesa el envío de la imagen $imagen = new Imagen(); $accion = $imagen->determinaAccion($campo); if ($accion != NOHACERNADA) { // El código 3 es no hacer nada. $mensaje = ""; - if (!$imagen->procesaEnvio("insertar", $campo, $mensaje)) { + if (!$imagen->procesaEnvio($campo, $mensaje)) { return $this->panelMensaje($mensaje, "danger", "ERROR PROCESANDO IMAGEN"); } - $hayImgen = true; + $hayImagen = true; + $campoImagen = $campo; } } else { @@ -374,7 +383,7 @@ class Mantenimiento { if (!$imagen->mueveImagenId($id, $mensaje)) { return $this->panelMensaje($mensaje, "danger", "ERROR COMPRIMIENDO IMAGEN"); } - $comando = "update " . $this->tabla . " set " . $campo . "='" . $imagen->archivoComprimido . "' where id='" . $id ."';"; + $comando = "update " . $this->tabla . " set " . $campoImagen . "='" . $imagen->archivoComprimido . "' where id='" . $id ."';"; if (!$this->bdd->ejecuta($comando)) { return $this->errorBD($comando); } @@ -598,7 +607,7 @@ class Mantenimiento { break; } $accion = $this->montaURL(); - $salida.='
'; + $mensaje .=''; + if ($tipoAccion == ANADIR || $tipoAccion == EDICION) { + $mensaje .= ''; + } $mensaje .= $this->creaModal($valor, 1); return $mensaje;