codeigniter $ this-> upload-> do_upload()= false [英] codeigniter $this->upload->do_upload() = false
本文介绍了codeigniter $ this-> upload-> do_upload()= false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试上传文件。我选择了一个文件然后提交,但是$ this-> upload-> do_upload()的结果始终为假。
I'm trying to upload a file. I select a file and then I submit it but result of $this->upload->do_upload() is always false.
这是我的表格;
<?php echo form_open_multipart(base_url('files/fileUpload')); ?>
<input type="file" name="userfile" class="btn btn-default" size="20"/>
<input type="submit" value="upload" />
</form>
这是我的控制者;
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function fileUpload(){
$this->load->library('upload');
$data = array('upload_data' => $this->upload->data());
var_dump($this->upload->do_upload());die;
}
我错过了什么吗?我需要做什么?
Do I miss something ? What do I need to do ?
谢谢..
推荐答案
控制器文件上传功能中的代码有问题
There is problem with code in controller fileUpload function
尝试以下代码
public function fileUpload(){
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload',$config);
$data = array('upload_data' => $this->upload->data());
var_dump($this->upload->do_upload());die;
}
在这里,您需要定义文件上传路径和文件允许类型。
Here you need to define file upload path and file allow types.
希望这对您有所帮助。
这篇关于codeigniter $ this-> upload-> do_upload()= false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文