Note that there are some explanatory texts on larger screens.

plurals
  1. POCI: Image Upload to Folder Not Working
    primarykey
    data
    text
    <p>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!</p> <p>Partial view below:</p> <pre><code>&lt;p&gt; &lt;label for="uEventFillByDateTime"&gt;Event Fill-by Date/Time:&lt;/label&gt; &lt;input type="text" id="uEventFillByDateTime" name="uEventFillByDateTime" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="uEventImage"&gt;Event Image:&lt;/label&gt; &lt;?php echo form_open_multipart('upload/do_upload');?&gt; &lt;input type="file" name="uEventImage" size="20" id="uEventImage" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="uEventKeywords"&gt;Event Keywords:&lt;/label&gt; &lt;textarea id="uEventKeywords" name="uEventKeywords"&gt;&lt;/textarea&gt; &lt;/p&gt; </code></pre> <p>Controller call:</p> <pre><code>public function createEvent() { if( !empty( $_POST ) ) { echo $this-&gt;event_model-&gt;createEvent(); } } </code></pre> <p>Model Code:</p> <pre><code>public function createEvent() { $this-&gt;image_path = realpath(APPPATH . 'event_images'); $config = array( 'allowed_types' =&gt; 'jpg|jpeg|gif|png', 'upload_path' =&gt; $this-&gt;image_path, 'max_size' =&gt; 2000, 'max_width' =&gt; 212, 'max_height' =&gt; 118 ); $this-&gt;load-&gt;library('upload', $config); $this-&gt;upload-&gt;do_upload(); $image_data = $this-&gt;upload-&gt;data(); /*format date time from string to mysql */ $cdt = $this-&gt;input-&gt;post( 'cEventDateTime', true ); $cdtMySQL = date("Y-m-d H:i:s", strtotime($cdt)); /*format fill-by date time from string to mysql */ $cfdt = $this-&gt;input-&gt;post( 'cEventFillByDateTime', true ); $cfdtMySQL = date("Y-m-d H:i:s", strtotime($cfdt)); $data = array( 'event_name' =&gt; $this-&gt;input-&gt;post( 'cEventName', true ), 'event_datetime' =&gt; $cdtMySQL, 'event_fillbydatetime' =&gt; $cfdtMySQL, 'event_keywords' =&gt; $this-&gt;input-&gt;post( 'cEventKeywords', true ), 'event_notes' =&gt; $this-&gt;input-&gt;post( 'cEventNotes', true ), 'event_featured' =&gt; $this-&gt;input-&gt;post( 'cEventFeatured', true ), 'fk_venue_id' =&gt; $this-&gt;input-&gt;post( 'cEventVenue', true ), 'fk_eventtype_id' =&gt; $this-&gt;input-&gt;post( 'cEventType', true ), 'fk_eventlifecycle_id' =&gt; $this-&gt;input-&gt;post( 'cEventlifecycle', true ), ); $this-&gt;db-&gt;insert( 'event', $data ); return $this-&gt;db-&gt;insert_id(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload