我使用来自 CI 的确切代码
https://www.codeigniter.com/user_guide/libraries/file_uploading.html
但它总是不断给我同样的错误
上传路径似乎无效。
文件夹在那里,路径没问题。文件夹有写权限。
控制器代码是这个
<?php
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = '/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
print_r($config);
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
//echo 'path : '.$config['upload_path'];
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
//echo "submited";
}
}?>