Codeigniter文件上传不会更改名称,也不会始终上传文件

时间:2016-06-24 18:22:57

标签: php codeigniter frameworks

我正在寻找codeigniter 3.0.6的帮助。我创建表单上传文件,然后更改它的名称。如果我跳过更改名称指令,它有时上传图像有时它不会,但当我打开它时它根本不上传。 这是我的控制者:

`
$this->load->model('car_model');

        if ($this->input->post('manufacturer')&&$this->input->post('model')&&$this->input->post('price')&&$this->input->post('body_style')&&$this->input->post('engine_size'))
        {
            $data['manufacturer']=$this->input->post('manufacturer');
            $data['model']=$this->input->post('model');
            $data['price']=$this->input->post('price');
            $data['body_style']=$this->input->post('body_style');
            $data['engine_size']=$this->input->post('engine_size');

            $query=$this->car_model->add_car($data);

            $query=$this->car_model->get_last_id();
            $number=$query->num_rows();
            $config['upload_path'] = './images/';
            $config['allowed_types'] = 'jpg|png';
            $config['max_size']     = '10000';  
            $config['file_name']='zdjecie'.$number.'.jpg';
            $this->load->library('upload', $config); 
            $this->upload->do_upload('photo');
            echo var_dump($_FILES);
            echo br().'zdjecie'.$number.'.jpg';`

和表格

    echo "<body>";
echo form_open_multipart('index.php/add_car/add');
echo "Producent:";
echo form_input('manufacturer');
echo br();
echo "Model:";
echo form_input('model');
echo br();
echo "Cena wynajmu za dzień:";
echo form_input('price');
echo br();
echo "Pojemność silnika(cm<sup>3</sup>):";
echo form_input('engine_size');
echo br();
echo "Rodzaj nadwozia:";
echo form_dropdown('body_style', $options);
echo br();
echo "Zdjecie:";
echo form_upload('photo');
echo br();
echo form_reset('reset','Wyczyść');
echo form_submit('send','Wyślij');

我应该改变什么来使其有效?

我使用xampp并在php.ini中设置文件限制设置为2mb

0 个答案:

没有答案