我有一個上傳圖像與另一個輸入字段的問題。無法使用codeigniter上傳圖像
這是我的看法
<?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
文件被上傳。
避免您的目錄名中有空格。使用類似save_here –
@YadhuBabu仍然不工作 –
任何錯誤消息 –