Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. public function add() {
  2. $path = 'img/noticias/';
  3.  
  4. $config = array(
  5. 'upload_path' => "./img/noticias/",
  6. 'allowed_types' => "jpg|png|jpeg",
  7. 'overwrite' => TRUE,
  8. 'max_size' => "2048000",
  9. 'max_height' => "768",
  10. 'max_width' => "1024"
  11. );
  12. $this->load->library('upload', $config);
  13.  
  14. if (!$this->upload->do_upload('addImage')) {
  15. $mensaje = array('error' => $this->upload->display_errors());
  16. die($mensaje['error']);
  17. }
  18. $file_info = $this->upload->data('addImage');
  19. $file_name = $file_info['file_type'];
  20. $datos = array(
  21. 'autor' => $this->input->post('addAutor'),
  22. 'nombre' => $this->input->post('addNombre'),
  23. 'ruta' => $path.$file_name,
  24. 'link' => $this->input->post('addLink')
  25. );
  26. echo "Nombre: ".$file_name;
  27. die();
  28. $resultado = $this->Articulos_Model->agregaArticulo($datos);
  29. if ($resultado) {
  30. redirect('index.php/Articulos', 'refresh');
  31. }
  32.  
  33.  
  34. }
  35.  
  36. <!-- Add Modal-->
  37. <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="editaArticulo" aria-hidden="true">
  38. <div class="modal-dialog" role="document">
  39. <div class="modal-content">
  40.  
  41. <?php echo form_open_multipart('index.php/Articulos/add'); ?>
  42. <div class="modal-header">
  43. <h5 class="modal-title text-center" id="editaArticulo">Agregar Artículo</h5>
  44. <button class="close" type="button" data-dismiss="modal" aria-label="Close">
  45. <span aria-hidden="true">×</span>
  46. </button>
  47. </div>
  48. <div class="modal-body">
  49.  
  50. <div class="form-group">
  51. <div class="form-label-group">
  52. <input name="addAutor" type="text" id="addAutor" class="form-control" placeholder="Autor" required="required" autofocus="autofocus">
  53. <label for="addAutor">Autor</label>
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <div class="form-label-group">
  58. <input name="addNombre" type="text" id="addNombre" class="form-control" placeholder="Nombre Artículo" required="required" autofocus="autofocus">
  59. <label for="addNombre">Nombre Artículo</label>
  60. </div>
  61. </div>
  62. <div class="form-group">
  63.  
  64. <label for="addFile">Eligir imagen</label>
  65. <input name="addImage" type="file" class="form-control-file" id="addFile" accept="image/png,image/jpg,image/jpeg">
  66.  
  67. </div>
  68. <div class="form-group">
  69. <div class="form-label-group">
  70. <input name="addLink" type="text" id="addLink" class="form-control" placeholder="Link del Artículo" required="required" autofocus="autofocus">
  71. <label for="addLink">Link del Artículo</label>
  72. </div>
  73. </div>
  74.  
  75. </div>
  76. <div class="modal-footer">
  77. <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
  78. <button class="btn btn-success" type="submit">Añadir</button>
  79. </div>
  80. <?php echo form_close(); ?>
  81.  
  82. </div>
  83. </div>
Add Comment
Please, Sign In to add comment