2

i am developing a tender management system and trying to attach the pdf file during the tender creation.

I have following controller and view, it is showing me some sort like no file is choosen. It is killing me.

function addtender() {
    $this->form->set_rules('name', 'Tender Name', 'required|min_length[4]');
    $this->form->set_rules('district', 'District Name', 'required|min_length[4]');
    $this->form->set_rules('department', 'Department Name', 'required|min_length[4]');
    $this->form->set_rules('userfile', 'Pdf File ', 'required');
    if($this->form->run()) {
    $config['upload_path'] = './assets/pdf/';
    $config['allowed_types'] = 'pdf';
    $config['max_size']    = 1000;
    $this->load->library('upload', $config);
    if (!$this->upload->do_upload('userfile'))
    {
        print_r($this->upload->display_errors());
         $this->data['page_data'] = 'admin/upload_view';
     }
    else
    {
          print_r($this->upload->data());
    }
    }
}

I have this controller code to upload pdf file codeignitor. My view is

    <div class="col-md-10">
<h3>Add Tenders</h3>
    <?=validation_errors('<div class="alert alert-danger">', '</div>');?>
    <?=form_open(site_url('admin/addtender'))?>
    <label>Tender Name</label>
    <input class="form-control" name="name" type="text">
    <label>District</label>
    <input type="text" name="district" class="form-control">
    <label>Department</label>
    <input type="text" name="department" class="form-control">
    <label>PDF file</label>
    <input type="file" name="userfile" class="form-control">
    <br>
    <input name="submit" type="submit" class="btn btn-primary" value="Add Tender">
</div>

It is saying that, You did not select a file to upload.

2 Answers 2

2

Try this

<form enctype="multipart/form-data">
</form>

place file upload code in form

Sign up to request clarification or add additional context in comments.

Comments

0

U have to make form multipart/form-data

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.