我正在尝试在codeigniter中上传图片。 p>
这里是我的 查看文件代码。 p>
< form action =“<?php echo site_url('pages / data_submitted')?>” method =“get”enctype =“multipart / form-data”>
Image:< input type =“file”name =“image”/>
< button>提交< / button>
< / form&gt ;
code> pre>
这是我的控制器代码。 p>
class Pages扩展CI_Controller
{
公共函数 data_submitted(){
$ config ['upload_path'] =“img /”;
$ this-> load-> library('upload',$ config);
$ this-> upload-&gt ; do_upload();
$ finfo = $ this-> upload-> data();
$ data = $ this-> upload-> display_errors();
$ this-> 负载>模型( 'user_model');
$的这 - > user_model-> insert_item($数据); \ N} \ N}
代码> PRE>
这里是我的模型代码 p>
<?php
class User_model extends CI_Model {
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @ :: __ construct();
}
公共函数insert_item($ item){
print_r($ item);
}
}
?>>
code> < / pre>
此代码有什么问题...
我传递$ data只是为了检查是否发生错误。
它显示“您没有选择要上传的文件。” 即使我选择了一个文件。
请帮助我。 p>
div>