Esempio n. 1
0
                mkdir($carpeta, 0755);
                if (isset($_FILES["imagen"])) {
                    $temp = $_FILES["imagen"]["tmp_name"];
                    $thumb = new Thumbnail($temp);
                    if ($thumb->error) {
                        echo $thumb->error;
                    } else {
                        $thumb->resize(200, 150);
                        $thumb->save_jpg($URL_long, $nombre_archivo);
                    }
                }
            } else {
                if (isset($_FILES["imagen"])) {
                    $temp = $_FILES["imagen"]["tmp_name"];
                    $thumb = new Thumbnail($temp);
                    if ($thumb->error) {
                        echo $thumb->error;
                    } else {
                        $thumb->resize(200, 150);
                        $thumb->save_jpg($URL_long, $nombre_archivo);
                    }
                }
            }
            //FIN cambio de imagen ************
            echo 1;
            return;
        }
    }
} else {
    header("Location: ../plantillas/errorPrivilegios.html");
}
Esempio n. 2
0
     //comprobamos si este archivo existe para no volverlo a copiar.
     //pero si quieren pueden obviar esto si no es necesario.
     //o pueden darle otro nombre para que no sobreescriba el actual.
     if (!file_exists($ruta)) {
         //aqui movemos el archivo desde la ruta temporal a nuestra ruta
         //usamos la variable $resultado para almacenar el resultado del proceso de mover el archivo
         //almacenara true o false
         $resultado = @move_uploaded_file($_FILES['imagen']['tmp_name'], $ruta);
         if ($resultado) {
             $temp = $_FILES['imagen']['tmp_name'];
             $thumb = new Thumbnail($temp);
             if ($thumb->error) {
                 echo $thumb->error;
             } else {
                 $thumb->resize(80);
                 $thumb->save_jpg("", "imagen");
             }
             $nombre = $_FILES['imagen']['name'];
             mysql_query("INSERT INTO voxs (id_autor, titulo, categoria, imagen, contenido, editores, fuente, fecha) VALUES ('{$id_autor}','{$titulo}', '{$categoria}','{$ruta}','{$contenido}','{$editores}','{$fuente}','{$fecha}')") or die(mysql_error());
             $dato = mysql_insert_id();
             mysql_query("INSERT INTO muro (id_perfil, id_autor, tipo, dato) VALUES ('{$id_autor}','{$id_autor}', '5','{$dato}')") or die(mysql_error());
             header("Location: ../vox.php?id={$dato}");
         } else {
             echo "ocurrio un error al mover el archivo.";
         }
     } else {
         echo $_FILES['imagen']['name'] . ", este archivo existe";
     }
 } else {
     echo "archivo no permitido, es tipo de archivo prohibido o excede el tamano de {$limite_kb} Kilobytes";
 }