 
			
				11/11/2015, 17:26
			
			
			     |  
      |    |    |    Fecha de Ingreso: noviembre-2015  
						Mensajes: 77
					  Antigüedad: 10 años Puntos: 2     |        |  
  |      como puedo conectar php con viewerjs        estoy en un proyecto con el que necsito visializar word en línea, me dieron este link http://viewerjs.org/instructions/  para descargar un script y con eso visualizar el documento en línea, pero no se como conectarlo en mi código. dejo el código del proyecto, si tienen una sugerencia creanme que va a ser muy valorada:    Index:   
<!DOCTYPE html> 
<!-- 
To change this license header, choose License Headers in Project Properties. 
To change this template file, choose Tools | Templates 
and open the template in the editor. 
--> 
<?php 
include_once 'config.inc.php'; 
$datos = array('.docx'); 
if (isset($_POST['subir'])) { 
    $nombre = $_FILES['archivo']['name']; 
    $tipo = $_FILES['archivo']['type']; 
    $tamanio = $_FILES['archivo']['size']; 
    $ruta = $_FILES['archivo']['tmp_name']; 
    $destino = "archivos/" . $nombre; 
    if ($nombre != "") { 
        if (copy($ruta, $destino)) { 
            $titulo= $_POST['titulo']; 
            $descri= $_POST['descripcion']; 
            $db=new Conect_MySql(); 
            $sql = "INSERT INTO tbl_documentos(titulo,descripcion,tamanio,tipo,nom  bre_archivo) VALUES('$titulo','$descri','$tamanio','$tipo','$no  mbre')"; 
            $query = $db->execute($sql); 
            if($query){ 
                echo "Se guardo correctamente"; 
            } 
        } else { 
            echo "Error"; 
        } 
    } 
} 
?>   
<html> 
    <head> 
        <meta charset="UTF-8"> 
        <title></title>     
    </head> 
    <body> 
        <div style="width: 500px;margin: auto;border: 1px solid blue;padding: 30px;"> 
            <h4>Subir PDF</h4> 
            <form method="post" action="" enctype="multipart/form-data"> 
                <table> 
                    <tr> 
                        <td><label>Titulo</label></td> 
                        <td><input type="text" name="titulo"></td> 
                    </tr> 
                    <tr> 
                        <td><label>Descripcion</label></td> 
                        <td><textarea name="descripcion"></textarea></td> 
                    </tr> 
                    <tr> 
                        <td colspan="2"><input type="file" name="archivo"></td> 
                    <tr> 
                        <td><input type="submit" value="subir" name="subir"></td> 
                        <td><a href="lista.php">lista</a></td>     
                    </tr> 
                </table> 
            </form>             
        </div> 
    </body> 
</html>    Una vez guardado pasa a esta lista: 
<html> 
    <head> 
        <meta charset="UTF-8"> 
        <title></title> 
    </head> 
    <body> 
        <table> 
            <tr> 
                <td>titulo</td> 
                <td>descripcion</td> 
                <td>tamaño</td> 
                <td>tipo</td> 
                <td>nombre</td> 
            </tr> 
        <?php 
        $datos = array('.docx'); 
        include 'config.inc.php'; 
        $db=new Conect_MySql(); 
            $sql = "select*from tbl_documentos"; 
            $query = $db->execute($sql); 
            while($datos=$db->fetch_row($query)){?> 
            <tr> 
                <td><?php echo $datos['titulo']; ?></td> 
                <td><?php echo $datos['descripcion']; ?></td> 
                <td><?php echo $datos['tamanio']; ?></td> 
                <td><?php echo $datos['tipo']; ?></td> 
                <td><a href="archivo.php?id=<?php echo $datos['id_documento']?>"><?php echo $datos['nombre_archivo']; ?></a></td> 
            </tr>   
          <?php  } ?>   
        </table> 
    </body> 
</html>    Para visualizar pasa aquí: 
<html> 
    <head> 
        <meta charset="UTF-8"> 
        <title></title> 
    </head> 
    <body> 
        <?php 
        include 'config.inc.php'; 
        $datos = array('.docx'); 
        $db=new Conect_MySql(); 
            $sql = "select*from tbl_documentos where id_documento=".$_GET['id']; 
            $query = $db->execute($sql); 
            if($datos=$db->fetch_row($query)){ 
                if($datos['nombre_archivo']==""){?> 
        <p>NO tiene archivos</p> 
                <?php }else{ ?> 
        <iframe height="300px" width="900px" src="archivos/<?php echo $datos['nombre_archivo']; ?>"></iframe>     
                <?php } } ?> 
                <br>     
    </body> 
</html>    la función que lo envía: 
<?php    
class Conect_MySql {    
     var $obj = array ( "dbname"	=>	"test", 
                       "dbuser"		=>	"root"		, 
                       "dbpwd"		=>	""		, 
                       "dbhost"		=>	"localhost"	);     
     var $q_id	=""; 
     var $ExeBit	=""; 
     var $db_connect_id = ""; 
     var $query_count   = 0; 
    private function connect(){ 
		$this->db_connect_id = mysqli_connect($this->obj['dbhost'],$this->obj['dbuser'],$this->obj['dbpwd'],$this->obj['dbname']); 
             if (!$this->db_connect_id) 
              { 
                echo (" Error no se puede conectar al servidor:".mysqli_connect_error()); 
    	  } 
  }   
function execute($query) {        
        $this->q_id = mysqli_query($this->db_connect_id,$query);         
        if(!$this->q_id ) { 
            $error1 = mysqli_error($this->db_connect_id); 
            die ("ERROR: error DB.<br> No Se Puede Ejecutar La Consulta:<br> $query <br>MySql Tipo De Error: $error1"); 
            exit; 
        }          
	$this->query_count++;  
	return $this->q_id;     
    }     
  public function fetch_row($q_id = "") { 
    	if ($q_id == "") { 
    		$q_id = $this->q_id; 
   	 	} 
        $result = mysqli_fetch_array($q_id); 
        return $result; 
    }	   
 public function get_num_rows() { 
        return mysqli_num_rows($this->q_id); 
    }   
public function get_row_affected(){ 
    return mysqli_affected_rows($this->db_connect_id); 
}   
public	function get_insert_id() { 
    return mysqli_insert_id($this->db_connect_id); 
}   
public  function free_result($q_id) { 
   		if($q_id == ""){ 
    		$q_id = $this->q_id; 
		} 
	mysqli_free_result($q_id); 
    }	   
public function close_db(){ 
        return mysqli_close($this->db_connect_id); 
    }   
public function more_result() { 
		return mysqli_more_results($this->db_connect_id); 
	} 
public function next_result() { 
		return mysqli_next_result($this->db_connect_id); 
	}   
  public function __construct(){ 
        $this->connect(); 
    }   
} 
?>     
				__________________  paco alonso           |