文件上存不了?
这是我的控制器 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.
" }
有点郁闷,版主大大们帮看看咋回事。 <input type="file" name="filename">
改成
<input type="file" name="userfile"> 版主回答的没错。
大家都不喜欢“仔细”看手册吗?仔细是一个程序员应有的素质。 看看我的帖子,你就明白了
http://codeigniter.org.cn/forums/thread-2875-1-1.html $this->upload->do_upload('filename') 我写了 <input type="file" name="userfile" id="face" />而且if( !$this->upload->do_upload("userfile")){...也写了还是会报you did not select afile to upload form要加上
enctype="multipart/form-data" 看下源码$this->upload->do_upload 你就知道原因了。
页:
[1]