アップロードする前に、異なるエリア名で複数のファイルをアップロードする際に問題があり、すべてのファイル名を変更する必要があります。異なる地域名の複数のアップロードとアップロード前にファイルの名前を変更
これはHTML形式です。
<input type="file" placeholder="" name="profilPic"/>
<input type="file" placeholder="" name="topPic"/>
これは、コントローラ
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
//$config['file_name'] = $this->session->sersession["id"];
$this->load->library('upload', $config);
$profilPic = $this->upload->do_upload('profilPic');
if (!$profilPic){
$error = array('error' => $this->upload->display_errors());
$this->session->set_flashdata("error", "profil pic was not uploaded= ");
}else{
$data = array('upload_data' => $this->upload->data());
$this->session->set_flashdata("success", "profil picture was uploaded.");
}
$topPic = $this->upload->do_upload('topPic');
if (!$topPic){
$error = array('error' => $this->upload->display_errors());
$this->session->set_flashdata("error", "top pic was not uploaded");
}else{
$data = array('upload_data' => $this->upload->data());
$this->session->set_flashdata("success", "this picture was uploaded.");
}
。注:画像は、ディレクトリにアップロードされています。しかし、私はあなたがまた、もちろん
$this->upload->initialize($config);
を使用して、第2のファイルアップロードの前に$config['file_name']
を設定することができ、すべてのファイルのファイル名を変更したいの前に「userID_profil.jpg」と「userID_top.jpg」のようにアップロード