Welcome Guest, Not a member yet? Register   Sign In
File is not uploaded
#1

[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 :&lt;input type="file" id="filename" name="filename"   /&gt;
<br>
&lt;input type="submit" value="Upload" name="submit"/&gt;
&lt;/form&gt;

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
#2

[eluser]alberta[/eluser]
finally em able to view the error, and error is

"You did not select a file to upload"

Why is this occuring??

Regards
#3

[eluser]Jondolar[/eluser]
What is the upload library?

Does the data get written to the database correctly? Is the problem that the file is not available? What part doesn't work? Typically, when you upload a file, you need to move it out of the tmp directory and into another directory. I don't see where you are doing that.
#4

[eluser]alberta[/eluser]
No data is not even being saved into database, when i set enctype="multipart/form-data" otherwise it is saved to database.
and file should be saved into folder name 'uploads' set by
Code:
$config['upload_path'] = './uploads/';

which part is missing then ?
#5

[eluser]alberta[/eluser]
when i only upload a file and doesn't include the other fields like "attached_on" and "is_active", then file is successfully uploaded. But when i include these two fields and uploas a file then it shows "You did not select a file to upload".

Should i create two forms, one for just uploading and second for other fields?? If some one has any other idea, kindly tell me..

Any help would be appreciated Smile




Theme © iAndrew 2016 - Forum software by © MyBB