Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. <p>Severity: Notice</p>
  2. <p>Message: Array to string conversion</p>
  3. <p>Filename: controllers/slider.php</p>
  4. <p>Line Number: 78</p>
  5.  
  6. //script
  7.  
  8. function save()
  9. {
  10. $('#btnSave').text('saving...'); //change button text
  11. $('#btnSave').attr('disabled',true); //set button disable
  12. var url;
  13.  
  14. if(save_method == 'add') {
  15. url = "<?php echo site_url('slider/upload')?>";
  16. } else {
  17. url = "<?php echo site_url('slider/ajax_update')?>";
  18. }
  19.  
  20. // ajax adding data to database
  21. $.ajax({
  22. url : url,
  23. type: "POST",
  24. data: $('#form').serialize(),
  25. dataType: "JSON",
  26. success: function(data)
  27. {
  28.  
  29. if(data.status) //if success close modal and reload ajax table
  30. {
  31. $('#modal_form').modal('hide');
  32. reload_table();
  33. }
  34. else
  35. {
  36. for (var i = 0; i < data.inputerror.length; i++)
  37. {
  38. $('[name="'+data.inputerror[i]+'"]').parent().parent().addClass('has-error'); //select parent twice to select div form-group class and add has-error class
  39. $('[name="'+data.inputerror[i]+'"]').next().text(data.error_string[i]); //select span help-block class set text error string
  40. }
  41. }
  42. $('#btnSave').text('save'); //change button text
  43. $('#btnSave').attr('disabled',false); //set button enable
  44.  
  45.  
  46. },
  47. error: function (jqXHR, textStatus, errorThrown)
  48. {
  49. alert('Error adding / update data'+errorThrown);
  50. $('#btnSave').text('save'); //change button text
  51. $('#btnSave').attr('disabled',false); //set button enable
  52.  
  53. }
  54. });
  55. }
  56.  
  57. //end script
  58.  
  59. <div class="modal-body form">
  60. <form id="form" class="form-horizontal" enctype="multipart/form-data" method="post" accept-charset="utf-8">
  61. <input type="hidden" value="" name="id"/>
  62. <div class="form-body">
  63.  
  64. <div class="form-group">
  65. <label class="control-label col-md-3">Title</label>
  66. <div class="col-md-9">
  67. <input name="title" placeholder="Caption" class="form-control" type="text">
  68. <span class="help-block"></span>
  69. </div>
  70. </div>
  71.  
  72. <div class="form-group">
  73.  
  74. <div class="col-md-12">
  75. <input type="file" name="userfile" class="form-control"/>
  76. <span class="help-block"></span>
  77. </div>
  78. </div>
  79.  
  80.  
  81.  
  82. </div>
  83. </form>
  84. </div>
  85.  
  86. public function __construct()
  87. {
  88. parent::__construct();
  89. $this->load->model('slider_model','person');
  90. }
  91.  
  92. public function ajax_add()
  93. {
  94.  
  95.  
  96. $this->_validate();
  97. $data = array(
  98. 'title' => $this->input->post('title'),
  99. 'image' => $this->input->post($this->upload()),
  100. );
  101. $insert = $this->person->save($data);
  102. echo json_encode(array("status" => TRUE));
  103. }
  104.  
  105. public function upload()
  106. {
  107. $config['upload_path'] = "./images/";
  108. $config['allowed_types'] = 'jpg|jpeg|gif|png';
  109. $this->load->library('upload',$config);
  110. $this->upload->do_upload();
  111. if(!$this->upload->do_upload()) {
  112. $error = array('error' =>$this->upload->display_errors());
  113. echo $error;
  114. }
  115. else {
  116. $file_data = $this->upload->data();
  117. $filename = $file_data['file_name'];
  118. $this->main_m->save('title',$filename);
  119. $data['img'] = base_url().'/images/'.$file_data['file_name'];
  120. return $filename;
  121. }
  122. }
  123.  
  124. public function save($data)
  125. {
  126. $this->db->insert($this->table, $data);
  127. return $this->db->insert_id();
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement