我正在使用 CI 上传多张图片,他们确实上传了。我也在尝试
使用以下代码调整它们的大小,只有第一个图像调整大小,其余的没有。他们以当前大小上传。怎么了?
任何帮助都会非常非常感激。
function doupload() {
$path = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value){
for($n=0; $n<=$count-1; $n++) {
$_FILES['userfile']['name']=$value['name'][$n];
$_FILES['userfile']['type'] = $value['type'][$n];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$n];
$_FILES['userfile']['error'] = $value['error'][$n];
$_FILES['userfile']['size'] = $value['size'][$n];
$config['upload_path'] = './images';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$path[] = $data['full_path']; //contains full path of every image
}
}
foreach($path as $p=>$ath){
$config1 = array(
'source_image' => $ath,
'new_image' => './images',
'maintain_ration' => true,
'overwrite' => true,
'width' => 600,
'height' => 400
);
$this->load->library('image_lib', $config1);
$this->image_lib->resize();
$this->image_lib->clear();
}
}