Herramientas Informaticas

Categoría: Sin categoría Página 20 de 51

SUBIR CUALQUIER TIPO DE ARCHIVOS EN CODE IGNITER

BUENOS DIAS AMIGOS, HACE UNAS SEMANAS ESTUVE BATALLANDO PARA PODER SUBIR UNOS ARCHIVOS QUE NO VENIAN EN LOS ARREGLOS DE MIMES.PHP, LOS AGREGUE ERAN UN .CER, Y AUN HACI NO ME SALIA, A LA UNICA SOLUCION QUE ME PERMITIO TRABAJAR Y DEJAR SUBIR ESE TIPO DE ARCHIVO FUE LA DE COMENTAR LA PARTE QUE VALIDABA LA EXTENCION DEL ARCHIVO, ANTES DE HACER ESTO ME MARCABA ESTE ERROR

The filetype you are attempting to upload is not allowed

DESPUES DE HACER MIL INTENTOS DE MIL MANERAS LA SOLUCION FUE LA SIGUENTE

AL PONER LA CONFIGURACION DEL TIPO DE ARCHIVO PONER LO DE ESTA FORMA 

   1: $config['allowed_types'] = '*';

Y  EN EL UPLOAD.PHP QUE SE ENCUENTRA EN CARPETADELPROYECTO/SYSTEM/LIBRARIES/UPLOAD.PHP ,  EN LA FUNCION do_upload() COMENTAR LA PARTE EN LA QUE VALIDE LA EXTENCION, Y VALIDALA TU MANUALMENTE A PARTIR DEL NOMBRE DEL ARCHIVO TOMANDO LOS 3 ULTIMOS CARACTERES.

LO QUE SE VA A COMENTAR ESTA MAS O MENOS POR LA LINEA 208

   1: // Is the file type allowed to be uploaded?

   2:        //ESTA ASY

   3:         if ( ! $this->is_allowed_filetype())

   4:         {

   5:             $this->set_error('upload_invalid_filetype');

   6:             return FALSE;

   7:         }

   8:  

   9:         //DEJARLO ASY

  10:         /*

  11:         if ( ! $this->is_allowed_filetype())

  12:         {

  13:             $this->set_error('upload_invalid_filetype');

  14:             return FALSE;

  15:         }

  16: */

DEJO ESTE APUNTE POR SI LO NECESITO LUEGO, LO PUBLICO POR SI A ALGUIEN MAS LE SIRVE, SI HAY OTRA MANERA SON BIENVENIDOS EN LOS COMENTARIOS

 

SALUDOS QUE PASEN BUEN FIN DE SEMANA

Subir archivos al servidor con CODEIGNITER PHP

Primero construimos el formulario

   1: <form id="registro" name="registro"  action="<?=base_url()?>index.php/ctrClientes/addClient" method="POST" enctype="multipart/form-data">

   2:   

   3:   

   4:   <b><label for="login">Nombres:</label></b>

   5:   <input type="text" name="NombreCliente" id="NombreCliente" onchange=""/> <br />

   6:   

   7:   

   8:   <b><label for="nom_usu">Apellidos:</label></b>

   9:   <input type="text" name="apellidos" id="apellidos"/><br />

  10:   

  11:   <b><label for="RFC">RFC:</label></b>

  12:   <input type="text" name="RFC" id="RFC" /><br />

  13:   

  14:   

  15:   <b><label for="psw1">Foto:</label></b>

  16:   <input type="text" name="Foto" id="Foto"/><br />

  17:   

  18:   

  19:   

  20:   

  21:   

  22:  

  23:   <input type="submit" name="submit" value="Registrar"/><br />

Ahora le movemos al controlador

   1: public function addClient()

   2:     {

   3:         

   4:     

   5:         

   6:         $config['upload_path'] = $this->folder;

   7:         $config['allowed_types'] = 'zip|rar|pdf|docx|txt|jpg';

   8:         $config['remove_spaces']=TRUE;

   9:         $config['max_size']    = '100000';

  10:         $config['overwrite'] = FALSE;

  11:         $config['encrypt_name'] = TRUE;

  12:  

  13:         $this->load->library('upload', $config);

  14:         

  15:  

  16:         if(!$this->upload->do_upload('cer')){

  17:             $error = array('error' => $this->upload->display_errors());

  18:             echo $this->upload->display_errors();

  19:             //$this->load->view('plantilla', $error);

  20:             }

  21:         else{

  22:             $upload_data = $this->upload->data(); 

  23:             $foto =   $upload_data['file_name'];

  24:         }

  25:         

  26:         

  27:                

  28:         

  29:         $data = array(

  30:                 "Nombre" => $this->input->post('NombreCliente'),

  31:                 "Apellido" => $this->input->post('apellidos'),

  32:                 "RFC" => $this->input->post('RFC'),

  33:                 "foto" => $nombreCertificado

  34:                 

  35:                 

  36:         );

  37:         

  38:         

  39:         //USANDO LA FUNCION DEL MODELO

  40:         

  41:         $this->clientsModel->insertClient($data);

  42:         

  43:        

  44:     }

Ahora solo lo insertamos con la ayuda del modelo

   1: public function insertBitacora($data){

   2:     $this->db->insert('bitacora',$data);

   3:     

   4: }

Ejemplos para ocultar y mostrar DIVS HTML

Primero hacemos las funciones una para cada boton

   1: function Agregar(){ 

   2:          document.getElementById("usuarioslocos").style.display = "none";

   3:         document.getElementById("divpararegistrar").style.display = "table";

   4:     }

   5:  

   6:     function Eliminar(){ 

   7:         if(obtenerRadioSeleccionado("form", "radios")!=false){

   8:             if(confirm("Deseas Realmente eliminar este registro?")){

   9:                 var id = obtenerRadioSeleccionado("form", "radios").value;

  10:                 location.href= "index.php/welcome/deleteUserId/" + id;

  11:             }

  12:                         else{ }

  13:         }

  14:         else{alert("No a seleccionado un registro !!");}

  15:     }

  16:  

  17:  

  18:     function Editar(){ 

  19:         

  20:                     if(obtenerRadioSeleccionado("form", "radios")!=false){

  21:             if(confirm("Desea Modificar el registro?")){

  22:                 var id = obtenerRadioSeleccionado("form", "radios").value;

  23:                 location.href= "index.php/welcome/updateUserId/" + id;

  24:             }

  25:                         else{ }

  26:         }

  27:         else{alert("No a seleccionado un registro !!");}

  28:     }

 

Creamos los botones y le asignamos una función a cada una

   1: <button onclick="Agregar()" type="button">Agregar

   2:         <button onclick="Editar()" type="button">Editar

   3:         <button onclick="Eliminar()" type="button">Eliminar

   4:         <button onclick="PDF()" type="button">PDF

Luego configuramos los divs

   1: <div id="usuarioslocos">

   2:             <table border="0" align="center" id="tabla">

   3:             <tr bgcolor="#7362ec" align="center" onmouseover='this.style.backgroundColor='#E13300''

   4:                                                  onmouseout='this.style.backgroundColor='#7362ec''>

   5:             

   6:             ID

   7:             NOMBRE  

   8:             APELLIDO 

   9:             RFC

  10:             CONTRASEÑA CERTIFICADO

  11:             CERTIFICADO

  12:             LLAVE

  13:             SELECCIONAR

  14:             

  15:             

  16:     

  17:             <?php

  18:             $colorfila=0;

  19:             

  20:             

  21:             if($records!=false){

  22:                foreach($records->result() as $row){

  23:                    if ($colorfila==0){ 

  24:                    $color= "#b5b5b5"; 

  25:                    $colorfila=1; 

  26:                     }else{ 

  27:                    $color="#f7f7f7"; 

  28:                    $colorfila=0; 

  29:                 }    

  30:                 echo "<tr bgcolor='".$color."' align='center' ";?> onmouseover="this.style.backgroundColor='#E13300'"

  31:                                                                    onmouseout="this.style.backgroundColor=''">

  32:                                                                 

  33:                                                                 <?php

  34:                 echo "";

  35:                 

  36:                 echo pintar($busqueda,$row->Cliente)." 

  37:                  ".pintar($busqueda,$row->Nombre)."

  38:                  ".pintar($busqueda,$row->Apellido)."

  39:                  ".pintar($busqueda,$row->RFC)." 

  40:                 ".pintar($busqueda,$row->contraCertificado)."

  41:                 ".pintar($busqueda,$row->nombreCertificado)."

  42:                 ".pintar($busqueda,$row->nombreLlave)."

  43:                 

  44:                 

  45:                 

  46:                 <input type='radio' name='radios' value='".$row->Cliente."'>";

  47:         

  48:                 echo "";

  49:             }

  50:             

  51:         }

  52:         ?>

  53:         

  54:         

  55:         

  56:  

  57:     

  58: 

  59:  

  60: 
<?php

  61: //echo $this->table->generate($records);

  62: //Creamos la páginación

  63:  echo $this->pagination->create_links();

  64:  ?>

  65:  

  66:  

  67:  

  68:  

  69:  

  70:  

  71:  

  72:  

  73:  <div id="divpararegistrar" hidden="true">

  74:  

  75:  

  76:     

  77:         

  78:         

  79:         <?php $jjq = base_url()."js/jquery-latest.js";

  80:               $jja = base_url()."js/jquery.validate.js";

  81:     

  82:     echo "";

  83:     echo "";

  84:     

  85:     ?>

  86:  

  87:         <style type="text/css">

  88:  

  89:             * { font-family: Verdana; font-size: 96%; }

  90:             label { width: 10em; float: left; }

  91:             label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }

  92:             p { clear: both; }

  93:             .submit { margin-left: 12em; }

  94:             em { font-weight: bold; padding-right: 1em; vertical-align: top;                     }

  95:         

  96:               

  97:  

  98: function validar(esto){ 

  99: valido=false; 

 100: for(a=0;a<esto.elements.length;a++){ 

 101: if(esto[a].type=="checkbox" && esto[a].checked==true){ 

 102: valido=true; 

 103: break 

 104: } 

 105:  

 106: } 

 107: if(!valido){ 

 108: alert("Chequee una casilla!");return false 

 109: } 

 110:  

 111: }  

 112:  

 113:  

 114:   

 115:             <script type="text/javascript">

 116:  

 117: $(document).ready(function(){

 118: $("body div:last").remove();

 119: });

 120: 

 121:  

 122:          

 123:   $(document).ready(function(){

 124:  $("#registro").validate({

 125:   rules: {

 126:     nom_usu: {

 127:       required: true,

 128:       maxlength: 25,

 129:       minlength:    3

 130:     },

 131:     

 132:     login: {

 133:       required: true,

 134:        maxlength: 2,

 135:       minlength:    2,

 136:       number: true

 137:     },

 138:     

 139:     psw: {

 140:       required: true,

 141:        maxlength: 10,

 142:       minlength:    6,

 143:       number: true,

 144:       equalTo: "#psw1"

 145:  

 146:     },

 147:     

 148:     psw1: {

 149:       required: true,

 150:        maxlength: 10,

 151:       minlength:    6,

 152:       number: true

 153:  

 154:     },

 155:     

 156:     acceso: {

 157:       required: true

 158:     },

 159:     

 160:     

 161:     status: {

 162:       required: true

 163:     }

 164:   }

 165: });

 166:  

 167:   });

 168:   

 169:   

 170:   

 171:       label{

 172:         width:150px;

 173:         display: inline-block;

 174:     }

 175:   

 176:   

 177: 

 178: 

 179: 

 180: <?php echo $_SESSION['nombre'];?>

 181:         

 182:         

 183:         

Registrar nuevo cliente

 184:          <div id="container" align="center">

 185:   

 186:   

 187:   

 188:   <form id="registro" name="registro"  action="index.php/ctrClientes/addClient" method="POST" enctype="multipart/form-data">

 189:     

 190:     

 191:     <label for="login">Nombres:

 192:     <input type="text" name="NombreCliente" id="NombreCliente" onchange=""/> 

 193:     

 194:     

 195:     <label for="nom_usu">Apellidos:

 196:     <input type="text" name="apellidos" id="apellidos"/>

 197:     

 198:     <label for="RFC">RFC:

 199:     <input type="text" name="RFC" id="RFC" />

 200:     

 201:     

 202:     <label for="psw1">Contraseña del Certificado

 203:     <input type="text" name="ContraCer" id="ContraCer"/>

 204:     

 205:     

 206:     <label for="file">Certificado:

 207:     <?php form_open_multipart('upload/do_upload'); ?>

 208:     <input type="file" name="cer" size="20000" /> 

 209:     

 210:     

 211:     

 212:     <label for="file">Archivo Llave:

 213:     <?php form_open_multipart('upload/do_upload'); ?>

 214:     <input type="file" name="key" size="20000" /> 

 215:     

 216:     

 217:     

 218:  

 219:     <input type="submit" name="submit" value="Registrar"/>

 220:     

 221:     

 222:     

 223:     

 224: 

 225: 

 226:  

 227:  

 228: 

 229: 

 230: 

 231:  

 232:  

 233:  

 234: 

 235:  

 236: 

Lo que ayer desprecie

Me lleno de sentimiento, tan solo evocar tu imagen

tu ojitos sollozando un poco antes de abandonarte

ahí te deje llorando di media vuelta y dije adiós

palabra que hoy me hiere y hasta me hace llorar mi error

 

y tu en donde estarás, sufriendo acaso sin mi

y yo deseando tener, lo que ayer desprecie

 

ahí te deje llorando di media vuelta y dije adiós

palabra que hoy me hiere y hasta me hace llorar mi error

y tu en donde estarás, sufriendo acaso sin mi

y yo deseando tener, lo que ayer desprecie

 

[youtube http://www.youtube.com/watch?v=oXcYSnqply0&hl=en&hd=1]
Lo que ayer desprecie

ALMACENES

WP_000312

LOS MOCHIS DESPUES DE LOS HUMANOS

WP_000313

LOS MOCHIS

WP_000277

UNKNOW

WP_000237

UNIVERSIDAD DE LOS MOCHIS

WP_000234

LOS MOCHIS

WP_000216

Página 20 de 51

Creado con WordPress & Tema de Anders Norén