[eluser]alberta[/eluser]
Hi all,
I am trying to upload file but it is not uploaded. Here is code of controller part.
Code:
function do_upload()
{
if ($this->input->post('submit') != '')
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|txt|pdf';
$config['max_size'] = '4096';
$this->load->library('upload', $config);
$data = array(
'project_id' => $this->input->post('id'),
'filename' => $this->input->post('filename'),
'is_active' => $this->input->post('is_active'),
'attached_on' => $this->input->post('attached_on'),
);
$id=$this->input->post('id');
$fname=$this->input->post('filename');
$filename = $id.'_'.$fname;
if ( ! $this->upload->do_upload($filename))
{
$data['error'] = array('error' => $this->upload->display_errors());
$this->parser->parse('/projects/attachment_form', $data);
}
else
{
$this->db->insert('attachements', $data);
redirect('projects/site_plan');
}
}
redirect('projects/site_plan');
}
In view file this code is written
Code:
<form method="post" action="{site_url}index.php/projects/do_upload" enctype="multipart/form-data">
{error}
<input type="hidden" value=<?php echo $this->uri->segment(3); ?> name="id"/>
File attached On:<input type="text" value="<?php echo date('Y-m-d'); ?>" name="attached_on"/>
<br>
Is Active :<select xml:lang="en" dir="ltr" name="is_active" id="is_active">
<option value="1" selected="yes">Yes</option>
<option value="0" >No</option>
</select>
<br>
Attach File :<input type="file" id="filename" name="filename" />
<br>
<input type="submit" value="Upload" name="submit"/>
</form>
Problem is neither file uploaded nor error message is displayed. And i even can't come to know what's wrong with file uploading. Can some one tell me any solution.
Thanks in advance