这是我的控制器 welcome.php
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->view('welcome_message');
}
function do_upload(){
$this->data['c_page'] = base_url();
$config['upload_path'] = $this->data['c_page'].'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload',$config);
if ( ! $this->upload->do_upload())
{ $this->data['error'] = array('error' => $this->upload->display_errors());
$this->load->view('welcome_message',$this->data);
}else{
$this->data['data'] = array('upload_data' => $this->upload->data());
$this->load->view('welcome_message',$this->data);
}
}
}
?>
-----------------------------------------------------------------------------
这是我的输出页面 welcome_message.php
<?php echo form_open_multipart('welcome/do_upload',array('name'=>'test','method'=>'post'))?>
<input type="file" name="filename">
<input type="submit" value="upload">
</form>
<?php
if (isset($error)) {
var_dump($error);
}
echo "<br>";
if (isset($data)) {
var_dump($data);
}
?>
----------------------------------------------------------------------------
文件的权限我也设为777了,我也在配置config.php里自动加载了url和form的帮助功能,可点上存后,还是打印出这个错误
array(1) { ["error"]=> string(43) "
You did not select a file to upload.
" }
有点郁闷,版主大大们帮看看咋回事。 |