Welcome Guest, Not a member yet? Register   Sign In
I need Help with Form Attachment
#1

(This post was last modified: 11-30-2021, 07:19 PM by php_rocs.)

When i insert the data upload does not work, could some one check what i am doing wrong here Sad 
Controller 


PHP Code:
<?php




class Fileservice extends CI_Controller
{
    /**
    *
    */
    public function __construct()
    {
        /*call CodeIgniter's default Constructor*/
        parent::__construct();

        /*load Model*/
        $this->load->model('Fileservice_model');
    }


    public function index()
    {


        $data = array();
        $data['page_title'] = 'Records';
        $data['records'] = $this->Fileservice_model->getRecords();
        $data['main_content'] = $this->load->view('admin/customers/recievedfiles'$dataTRUE);
        $this->load->view('admin/index'$data);

    }



    public function recievedfiles()
    {
        $data = array();
        $data['page_title'] = 'recievedfiles';
        $data['records'] = $this->Fileservice_model->getRecords();
        $data['main_content'] = $this->load->view('admin/customers/recievedfiles'$datatrue);
        $this->load->view('admin/index'$data);


    }
    public function sendfile()
    {
        $data = array();
        $data['page_title'] = 'sendfile';
        $data['records'] = $this->Fileservice_model->getRecords();
        $data['main_content'] = $this->load->view('admin/customers/sendfile'$datatrue);
        $this->load->view('admin/index'$data);


    }
    public function viewfile()
    {
        $data = array();
        $data['page_title'] = 'viewfile';
        $data['viewfile'] = $this->Fileservice_model->getRecords();
        $data['main_content'] = $this->load->view('admin/customers/viewfile'$datatrue);
        $this->load->view('admin/index'$data);


    }

    public function record($record_id){

        $data = array();
        $data['page_title'] = 'Record';
        $data['record'] =  $this->Fileservice_model->getRecordById($record_id);

        if( !$data['record']){
            $this->session->set_flashdata('error'"record not found");
            redirect(site_url('admin/fileservice'));
        }

        $data['main_content'] = $this->load->view('admin/customers/viewfile'$dataTRUE);
        $this->load->view('admin/index'$data);

    }


    public function deleterecord($record_id){



        $this->Fileservice_model->deleteRecordById($record_id);

        $this->session->set_flashdata('success'"record deleted");
        redirect(site_url('admin/fileservice/recievedfiles'));

    }
    public function do_upload()
    {
        $config['upload_path']          './uploads/';
        $config['allowed_types'] = '*';


        $this->load->library('upload'$config);

        if ( ! $this->upload->do_upload('sendfile'))
        {
            $error = array('error' => $this->upload->display_errors());

            $this->load->view('sendfile'$error);
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());

        }
        redirect(site_url('admin/fileservice/recievedfiles'));

    }

    /*Insert*/
    public function savedata()
    {


        /*Check submit button */


        $data['ticket_id']      $this->input->post('ticket_id');
        $data['vmake']          $this->input->post('vmake');
        $data['vmodel']        $this->input->post('vmodel');
        $data['vengine']        $this->input->post('vengine');
        $data['vfuel']          $this->input->post('vfuel');
        $data['ebrand']        $this->input->post('ebrand');
        $data['etype']          $this->input->post('etype');
        $data['esw']            $this->input->post('esw');
        $data['ehw']            $this->input->post('ehw');
        $data['esolutions']    $this->input->post('esolutions');
        $data['etuning']        $this->input->post('etuning');
        $data['etool']          $this->input->post('etool');
        $data['emessage']      $this->input->post('emessage');
        $data['efile']          $this->input->post('efile');
        $data['efilemod']      $this->input->post('efilemod');
        $data['status']        $this->input->post('status');
        $data['date_created']  date('Y-m-d H:i:s');

        $response $this->Fileservice_model->saveRecord($data);




            if ($response) {

            $this->session->set_flashdata('success'"Records Saved Successfully . ID :" $response);

        } else {
            $this->session->set_flashdata('error'"Error occurred");
        }



        redirect(site_url('admin/fileservice/recievedfiles'));


    





}

View
PHP Code:
<!-- ============================================================== -->
<!-- 
Container fluid  -->
<!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- Bread crumb and right sidebar toggle -->
    <!-- ============================================================== -->
    <div class="row page-titles">
        <div class="col-md-5 col-8 align-self-center">
            <h3 class="text-themecolor m-b-0 m-t-0">Send File</h3>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                <li class="breadcrumb-item active">Send File</li>
            </ol>
        </div>
        <div class="col-md-7 col-4 align-self-center">
            <div class="d-flex m-t-10 justify-content-end">
                <div class="d-flex m-r-20 m-l-10 hidden-md-down">
                    <div class="chart-text m-r-10">
                        <h6 class="m-b-0"><small>THIS MONTH</small></h6>
                        <h4 class="m-t-0 text-info">$58,356</h4></div>
                    <div class="spark-chart">
                        <div id="monthchart"></div>
                    </div>
                </div>
                <div class="d-flex m-r-20 m-l-10 hidden-md-down">
                    <div class="chart-text m-r-10">

                    </div>
                </div>
                <div class="">
                    <button class="right-side-toggle waves-effect waves-light btn-success btn btn-circle btn-sm pull-right m-l-10"><class="ti-settings text-white"></i></button>
                </div>
            </div>
        </div>
    </div>
    <!-- ============================================================== -->
    <!-- End Bread crumb and right sidebar toggle -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- Start Page Content -->
    <!-- ============================================================== -->

    <div class=row>
    <div class="col-md-6">

        <?php echo form_open_multipart('admin/fileservice/do_upload','admin/fileservice/savedata');?>


        <div class="card">
                    <div class="card-body">
                        <h3 class="card-title">Vehicle Data</h3>

                        <input class="form-control"    name="vmake"        type="text" placeholder="Make">
                        <input class="form-control"    name="vmodel"      type="text" placeholder="Model">
                        <input class="form-control"    name="vengine"      type="text" placeholder="Engine Size">
                        <input class="form-control"    name="vfuel"        type="text" placeholder="Fuel Type">

                    </div>
                </div>
            </div>


            <div class="col-md-6">
                <div class="card">
                    <div class="card-body">
                        <h3 class="card-title">ECU Data</h3>

                        <select class="form-control">
                            <option>ECU select</option>
                        </select>


                        <select class="form-control">
                            <option>Type select</option>
                        </select>

                        <input class="form-control"      name="esw"    type="text" placeholder="ECU Software Number">
                        <input class="form-control"      name="ehw"    type="text" placeholder="ECU Hardware Number">
                    </div>
            </div>
            </div>

        </div>
<row>

        <div class=row>

        <div class="col-md-6">
            <div class="card">
                <div class="card-body">
                    <h3 class="card-title">Tuning & Tools </h3>
                    <input class="form-control"    name=  "esolutions"      type="text" placeholder="Select Solution">
                    <input class="form-control"    name=  "etuning"          type="text" placeholder="Select Tuning">
                    <input class="form-control"    name=  "etool"            type="text" placeholder="Tool Used">


                </div>
            </div>
        </div>



        <div class="col-md-6">
            <div class="card">
                <div class="card-body">

                    <div class="input-group mb-3">



                        <input type="file" name="sendfile"/>


                    </div>



                    <div class="form-group">
                        <h3>Message <span class="text-danger">*</span></h3>
                        <div class="controls">
                            <textarea name="emessage" id="textarea" class="form-control" required ></textarea>
                        </div>
                    </div>



                      <button type="submit" class="btn btn-block btn-lg btn-info"value="upload" >Send File</button>



                        <?php echo form_close() ?>


                </div>
            </div>
            </div>

        </div>




<!-- ============================================================== -->
<!-- End Container fluid  -->
<!-- ============================================================== -->
<!-- ============================================================== --> 
Reply
#2

(This post was last modified: 11-30-2021, 07:20 PM by php_rocs.)

@ugndz ,

We can't see your code. Please use the code insert feature so that we can see the code in a readable format.

Never mind. I fixed it for you.
Reply
#3

Thank you sir

i would appreaciate if you could tell me what i am doing wrong in the code?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB