写真をアップロードできません。PHP でエラーが発生する アップロードするファイルが選択されていません。ビューのコードは次のとおりです
<?php echo form_open_multipart('upload/do_upload_member_photo');?>
<div class="tab_content" id="tab2" style="display: none;">
<input type="file" id="file1" name="file1" style="">
<a href="#" onclick="openFileOption();return;"> <div class="one">Upload Photo / Video</div></a>
<a href="#"> <div class="two">Create Photo Album</div></a>
<textarea name="post" placeholder="What's on your mind?" style="margin: 0px; width: 437px; height: 39px; border:1px solid #999"></textarea>
<button type="submit" class="post_button" style="float:right; color:#fff">Post</button>
</div>
</form>
<script>
function openFileOption()
{
document.getElementById("file1").click();
}
</script>
コントローラーのコードは
function do_upload_member_photo()
{
$this->load->helper(array('form', 'url'));
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$config['width'] = '150';
$config['height'] = '150';
$config['maintain_ration'] =TRUE;
$config['overwrite']=TRUE;
$config['file_name'] = $_FILES['file1']['name'][0];;
if(!file_exists('./uploads/' . $this->session->userdata('user_id')))
{
mkdir('./uploads/' . $this->session->userdata('user_id'), 0777);
}
$config['upload_path'] = './uploads/'.$this->session->userdata('user_id');
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
}
}