doushi1847 2014-11-25 04:42
浏览 74

codeigniter do_upload在ubuntu服务器上缺少参数1

i have a question about codeigniter, why i have missing argument on do_upload excel file , on localhost it's work but after copy into linux server it have error like this :

A PHP Error was encountered Severity: Warning Message: Missing argument 1 for chapter::do_upload, called in /var/www/html/myfolder/application/controller/chapter.php on line 19 and defined Filename: contollers/chapter.php Line Number:32

what i miss on this code ?

here is my view code :

<center>
</br>
</br>
<?php  echo form_open_multipart('chapter') . "
"; ?>
<table>
  <tr>
  <td><input type="file" id="file_upload" name="userfile" size="20" /></td>
   <td valign="top" >
   <?php echo form_submit('submit', 'Upload'); ?></td>
 </tr>
</table>
<?php echo form_close(); ?>
<?php
if ($this->session->flashdata('msg_excel')){
?>
<div class="msg"><?php echo $this->session->flashdata('msg_excel'); ?></div>
<?php } ?>
</br>
</br>
</div>
</center>

mycontoller :

<?php
class Chapter extends CI_Controller {
 function __construct()
 {
   parent::__construct();
   $this->load->model('Querypage');
   $this->load->model('m_login');
   $this->load->helper(array('form', 'url', 'inflector'));
   $this->load->library('form_validation');
 }
 public function index()
 {
       if ($this->input->post('submit'))
       {   
$this->do_upload();
        $this->load->view('chapter');
}
  else
  {
   $this->load->model('m_jadwal','',TRUE);
   $user = $this->session->userdata('username');
   $data['pengguna'] = $this->m_login->dataPengguna($user);
   $data['kdsmtaktif'] = $this->m_login->smtaktif();
   $this->load->view('aka_v', $data);
   $this->load->view('chapter');
  }
 }

public function do_upload()
{
    $config['upload_path'] = './temp_upload/';
    $config['allowed_types'] = 'xls';

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

     if ( ! $this->upload->do_upload())
     {
            $data = array('error' => $this->upload->display_errors());
            $this->session->set_flashdata('msg_excel', 'Gagal Memasukkan data. Cek file anda, hanya .xls yang diperbolehkan.');
     }
     else
     {
            $data = array('error' => false);
            $upload_data = $this->upload->data();

            $this->load->library('excel_reader');
            $this->excel_reader->setOutputEncoding('CP1251');

            $file =  $upload_data['full_path'];
            $this->excel_reader->read($file);
            error_reporting(E_ALL ^ E_NOTICE);

            // Sheet 1
            $data = $this->excel_reader->sheets[0] ;
            $dataexcel = Array();
            for ($i = 8; $i <= $data['numRows']; $i++) {
               if($data['cells'][$i][1] == '') break;
               $dataexcel[$i-1]['data1'] = $data['cells'][$i][1];
             $dataexcel[$i-1]['data2'] = $data['cells'][$i][2];      
            $dataexcel[$i-1]['data3'] = $data['cells'][$i][3];
            }
    //cek data
    $check= $this->Querypage->search_chapter($dataexcel);
    if (count($check) > 0)
    {
      $this->Querypage->update_chapter($dataexcel);
      // set pesan
      $this->session->set_flashdata('msg_excel', 'update data success');
  }else{
      $this->Querypage->insert_chapter($dataexcel);
      // set pesan
      $this->session->set_flashdata('msg_excel', 'inserting data success');
  }
  }
        echo " <script>
            history.go(-2);
          </script>";
  }
}
?>
  • 写回答

2条回答 默认 最新

  • dongshao9106 2014-11-25 09:33
    关注

    In your controller change:

    public function do_upload($user, $kdsmt)  //on line 32
    

    To:

    public function do_upload()
    

    You aren't using either params in your method so there is no need to have them. More importantly, if you have declare params with a function and don't give them a default value then PHP will through an error if you don't pass anything through to them.

    Hope this helps!

    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?