我的上传图片与另一个输入字段有问题。
这是我的观点
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="upload" />
<input type="submit" value="upload" class="btn" id="upload_submit" name="upload_submit">
这是我的控制器
function do_upload()
{
$file_paths = "C:/Users/admin/Desktop/save_here/";
$this->load->helper('form');
$this->load->helper('url');
$this->load->library('upload');
if($this->input->post('upload_submit')){
if(isset($_FILES["upload"]["tmp_name"])){
$config['upload_path'] = $file_paths;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('upload')){
$error = array("status"=>"0",'error' => $this->upload->display_errors(),'upload_data'=>'');
}else{
$data = array("status"=>"1",'error'=>'','upload_data' => $this->upload->data());
}
}
}
}
我的问题是我无法上传图片,或者save_here
文件中没有上传图片。
答案 0 :(得分:0)
像这样更改文件路径
$ file_paths =“C:\ Users \ admin \ Desktop \ save_here \”;
答案 1 :(得分:0)
试试这个。你必须用config
初始化上传库
POST