CI的新用户, 我正在尝试使用我认为的好方法进行简单上传(发生了这种情况) 它没有运行。
简单的控制器, 简单的表格视图, 简单模型,带有配置参数的加载上传库 userfile的路径(上传文件夹:777)是正确的
似乎处理正常,但不是文件夹中的文件,当我正在测试时 do_upload(),我有假...?好像是do_upload();没被称为
控制器
class Ct_admin_add extends CI_Controller {
public function index()
{
$this->load->view('view_admin_header');
$msg['msg_file'] = '';
$this->load->model('form_admin_add_model');
if($this->input->post('Upload'))
{
$this->form_admin_add_model->do_upload();
}
$this->load->view('form_admin_add', $msg);
$this->load->view('view_admin_footer');
}
}
视图
<?php echo form_open_multipart('ct_admin_add');?>
<?php echo form_upload('userfile');?><br />
<?php echo form_submit('Upload', 'Charger');?><br />
<?php echo $msg_file; ?>
<?php echo form_close(); ?>
模型
<?php
class Form_admin_add_model extends CI_Model{
var $userfile_path;
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->userfile_path = APPPATH.'../userfile/';
}
function do_upload()
{
$config = array(
'upload_path' => $this->userfile_path,
'allowed_types' => 'gif|jpg|png',
'max_size'=> '100',
'max_width' => '1024',
'max_height' => '768',
'overwrite' => TRUE,
'encrypt_name' => FALSE,
'remove_spaces' => TRUE
);
$this->load->library('upload', $config);
if ( ! is_dir($config['upload_path']) ) die("THE UPLOAD DIRECTORY DOES NOT EXIST");
$test = $this->upload->do_upload();
var_dump($test);
}
}
任何提示?