Welcome Guest, Not a member yet? Register   Sign In
Upload Image: Not being placed into folder
#1

[eluser]ShawnMA[/eluser]
I'm having difficulty determining what I'm doing wrong/how to troubleshoot it, when attempting to use the upload library. I have a form with multiple fields (mostly text), with one image upload field. Data entered into the text fields is properly populated into my database, but the image file that the user browses to to upload, is not showing up in the folder I create at the root, its permissions permit it to be written to. All help is greatly appreciated. Thanks!

Partial view below:

Code:
<p>
               <label for="uEventFillByDateTime">Event Fill-by Date/Time:</label>
               &lt;input type="text" id="uEventFillByDateTime" name="uEventFillByDateTime" /&gt;
              
           </p>
           <p>
               <label for="uEventImage">Event Image:</label>
                &lt;?php echo form_open_multipart('upload/do_upload');?&gt;
                &lt;input type="file" name="uEventImage" size="20" id="uEventImage" /&gt;
           </p>
          
           <p>
               <label for="uEventKeywords">Event Keywords:</label>
               &lt;textarea id="uEventKeywords" name="uEventKeywords"&gt;&lt;/textarea>
           </p>

Controller call:

Code:
public function createEvent() {
                if( !empty( $_POST ) ) {
                    echo $this->event_model->createEvent();
                }
        }

Model code:
Code:
public function createEvent() {
            
            $this->image_path = realpath(APPPATH . 'event_images');
              
            $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->image_path,
            'max_size' => 2000,
            'max_width' => 212,
            'max_height' => 118
        );
                        
            $this->load->library('upload', $config);
            $this->upload->do_upload();
            $image_data = $this->upload->data();
          
            /*format date time from string to mysql */
            $cdt = $this->input->post( 'cEventDateTime', true );
            $cdtMySQL = date("Y-m-d H:i:s", strtotime($cdt));
            /*format fill-by date time from string to mysql */
            $cfdt = $this->input->post( 'cEventFillByDateTime', true );
            $cfdtMySQL = date("Y-m-d H:i:s", strtotime($cfdt));
  
            $data = array(
                'event_name'  => $this->input->post( 'cEventName', true ),
                'event_datetime' => $cdtMySQL,
                'event_fillbydatetime' => $cfdtMySQL,
                'event_keywords'  => $this->input->post( 'cEventKeywords', true ),
                'event_notes'  => $this->input->post( 'cEventNotes', true ),
                'event_featured'  => $this->input->post( 'cEventFeatured', true ),
                'fk_venue_id'  => $this->input->post( 'cEventVenue', true ),
                'fk_eventtype_id'  => $this->input->post( 'cEventType', true ),
                'fk_eventlifecycle_id'  => $this->input->post( 'cEventlifecycle', true ),
            );
            $this->db->insert( 'event', $data );
            return $this->db->insert_id();
        }




Theme © iAndrew 2016 - Forum software by © MyBB