当我尝试上传10个以上的图像时,我会在codeigniter中上传多个图像,它显示空白屏幕,没有任何错误,但是当我上传10个或少于10个图像时,相同的代码工作。我无法找出问题,请帮助。
我还在 php.ini 中设置了以下设置:
upload_max_filesize = 128M
max_file_uploads = 50
这是我的HTML代码:
<form method="post" role="form" enctype="multipart/form-data" action="<?php echo base_url();?>admin/allbums/add_new">
<input type="file" name="myfile[]" multiple="multiple">
<input type="hidden" name="user_id" value="<?php echo $user_id;?>">
</form>
这是我的控制器中的代码:
public function add_new() {
$config['upload_path']="./uploads/";
$config['allowed_types']='*';
$config['encrypt_name'] = TRUE;
$config['overwrite'] = false;
$this->load->library('upload', $config);
if($this->upload->do_multi_upload("myfile")) {
$file_arr = $this->upload->get_multi_upload_data();
$arr_lenth = count($file_arr);
$user_id = $_POST['user_id'];
for($i=0;$i<=$arr_lenth-1;$i++) {
$data[] = array(
'img_name' => $file_arr[$i]['file_name'],
'size' => $file_arr[$i]['file_size'],
'user_id' => $user_id
);
}
$this->allbum_model->insert_allbum($user_id,$data);
$data['success'] = '<div class="note note-success"> Allbum Added Successfully!</div>';
$data['user_id'] = $user_id;
$this->load->view('admin/allbum', $data);
} else { // else if file not uploaded correctly
echo $this->upload->display_errors();
}
答案 0 :(得分:1)
你还应该将 post_max_size 添加到php.ini,以便能够发送数据
;Maximum allowed size for uploaded files.
upload_max_filesize = 128M
;Must be greater than or equal to upload_max_filesize
post_max_size=128M