如何使用codeigniter

时间:2018-06-16 05:59:50

标签: php codeigniter-3

在我的项目中,我有上传图片的文件夹,我想通过用户输入更新上传的图片,我该怎么做?我们有任何命令吗?
这是上传代码

if(!empty($_FILES['userFiles']['name'])){  
$file_name = $_FILES['userFiles']['name'];  
$f_name = addslashes(preg_replace('/\s+/', '_', $data['f_name']));  
$x = explode('.',$file_name);  
$_FILES['userFile']['name'] = $f_name.'.'.end($x);  
$_FILES['userFile']['type'] = $_FILES['userFiles']['type'];  
$_FILES['userFile']['tmp_name'] = $_FILES['userFiles']['tmp_name'];  
$_FILES['userFile']['error'] = $_FILES['userFiles']['error'];  
$_FILES['userFile']['size'] = $_FILES['userFiles']['size']; 

$uploadPath = 'User_gallary';  

$config['overwrite'] = false;  
$config['upload_path'] = $uploadPath;  
$config['allowed_types'] = 'jpg|png|jpeg|JPEG|PNG|JPEG';    
$this->load->library('image_lib');  
$this->load->library('upload', $config);  
$this->upload->initialize($config);  
if($this->upload->do_upload('userFile')){  
$upload_data = $this->upload->data();  
$data['user_image'] = $upload_data['file_name'];    

0 个答案:

没有答案