需要将图像上传到文件夹并将文件名插入MySQL,图像名称应该是唯一的。 我的控制器代码是:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$config['upload_path'] = 'uploads/gallery/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$this->load->library('upload', $config);
$upload = $this->upload->do_upload('image_file');
$title=$this->input->post('title');
$value=array(
'title' => $title,
'image_name' => $new_image_name,
'crop_name' => $crop_image_name
);
}
答案 0 :(得分:0)
喜欢这个
public function uploadImageFile() //gallery insert
{
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$new_image_name = time() . str_replace(str_split(' ()\\/,:*?"<>|'), '',
$_FILES['image_file']['name']);
$config['upload_path'] = 'uploads/gallery/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['file_name'] = $new_image_name;
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['$min_width'] = '0';
$config['min_height'] = '0';
$this->load->library('upload', $config);
$upload = $this->upload->do_upload('image_file');
$title=$this->input->post('title');
$value=array('title'=>$title,'image_name'=>
$new_image_name,'crop_name'=>$crop_image_name);}