我有一个codeigniter网站,有多个图像上传,我的控制器如下所示:
$this->load->library('upload');
$image = array();
$ImageCount = count($_FILES['pimage']['name']);
for($i = 0; $i < $ImageCount; $i++){
$_FILES['file']['name'] = $_FILES['pimage']['name'][$i];
$_FILES['file']['type'] = $_FILES['pimage']['type'][$i];
$_FILES['file']['tmp_name'] = $_FILES['pimage']['tmp_name'][$i];
$_FILES['file']['error'] = $_FILES['pimage']['error'][$i];
$_FILES['file']['size'] = $_FILES['pimage']['size'][$i];
// File upload configuration
$uploadPath = './uploads/products/';
$config['upload_path'] = $uploadPath;
$config['allowed_types'] = 'jpg|jpeg|png|gif';
// Load and initialize upload library
$this->load->library('upload', $config);
$this->upload->initialize($config);
// Upload file to server
if($this->upload->do_upload('file')){
// Uploaded file data
$imageData = $this->upload->data();
// $uploadImgData[$i]['image_name'] = $imageData['file_name'];
$uploadImgData[] = $imageData['file_name'];
$data = array('upload_data' => $this->upload->data());
$path=$data['upload_data']['full_path'];
$q['name']=$data['upload_data']['file_name'];
$config['image_library'] = 'gd2';
$config['source_image'] = $path;
$config['maintain_ratio'] = true;
$config['width'] = 320;
$config['height'] = 230;
$this->load->library('image_lib');
$this->image_lib->initialize($config);
$this->image_lib->resize();
unset($config);
$this->load->library('image_lib');
$this->image_lib->clear();
}
}
图像正在上传,但调整大小没有发生,任何人都可以请告诉我什么是错的,在这里,提前感谢
1条答案
按热度按时间lb3vh1jj1#
尝试以下更正: