我在尝试上传多张图片时不断获得You have not selected a file to upload
:
// Needs PartID from main part insert
$PartImageName = $this->input->post('PartImageName');
$PartImageAlt = $this->input->post('PartImageAlt');
$PartImageMain = $this->input->post('PartImageMain');
$PartImage = $this->input->post('PartImage');
for($i = 0; $i < count($PartImageName); ++$i){
// Need to upload and resize the image(s)...make sure they are image(s), and are less than 5M in size
//$PartImage[$i] is the file
$fconfig['upload_path'] = PART_IMAGE_PATH;
$fconfig['allowed_types'] = 'gif|jpg|png|bmp';
$fconfig['max_size'] = '51200000000';
$fconfig['remove_spaces'] = TRUE;
$this->upload->initialize($fconfig);
// upload the initial image:
$this->upload->do_upload('PartImage[]');
var_dump($fconfig);
var_dump($this->upload->display_errors());
$upload_data = $this->upload->data();
$file_name = $upload_data['file_name'];
// now resize it:
$rconfig['image_library'] = 'gd2';
$rconfig['source_image'] = PART_IMAGE_PATH . $file_name;
$rconfig['maintain_ratio'] = TRUE;
$rconfig['width'] = 640;
$rconfig['height'] = 480;
$this->image_lib->initialize($rconfig);
$this->image_lib->resize();
var_dump($rconfig);
var_dump($this->image_lib->display_errors());
$this->image_lib->clear();
// now create a thumbnail
$tconfig['image_library'] = 'gd2';
$tconfig['source_image'] = PART_IMAGE_PATH . $file_name;
$tconfig['new_image'] = PART_IMAGE_THUMB_PATH . $file_name;
$tconfig['maintain_ratio'] = FALSE;
$tconfig['width'] = 194;
$tconfig['height'] = 146;
$this->image_lib->initialize($tconfig);
$this->image_lib->resize();
var_dump($tconfig);
var_dump($this->image_lib->display_errors());
$this->image_lib->clear();
$data = array('partImageName'=>$PartImageName[$i],
'partImageAlt'=>$PartImageAlt[$i],
'partImageMain'=>(isset($PartImageMain[$i])) ? $PartImageMain[$i] : 0,
'partImage'=>$file_name,
'partID'=>$PartID,);
$this->db->insert('TblPartOptionImages', $data);
}
我做错了什么,我该如何解决?
文件字段为:<input type="file" id="PartImage" name="PartImage[]" />
我已验证文件路径是世界可写的