Solved: non-object error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Solved: non-object error (/showthread.php?tid=70563) |
Solved: non-object error - davy_yg - 04-26-2018 Hello, I am trying to view the file image after uploading and I am getting non-object error. How to call the file name? upload_success.php Code: [code] <?php endforeach; ?> </ul> <img src="uploads/".$upload_data->file_name> <p><?php echo anchor('upload', 'Upload Another File!'); ?></p> </body> </html>[/code] RE: non-object error - InsiteFX - 04-27-2018 Because it is an Associated array and your trying to access it as an object. Do you even know the difference between an associated array or an object etc;? RE: non-object error - davy_yg - 04-28-2018 associated array something like: https://www.w3schools.com/php/php_arrays.asp ? How to fix the code? RE: non-object error - davy_yg - 04-28-2018 I already able to capture the file name but unable to print it out correctly. controllers/upload_image.php $data = array('upload_data' => $this->upload->data(), 'file_name' => $this->upload->data('file_name') ); $this->photo_model->insert_pic(); $this->load->view('upload_success', $data); views/upload_success.php <img scr="uploads/"<?php echo $file_name; ?>> If I checked through inspect element I get this html code: <img src="uploads/"davy210.png=""> which is in correct. RE: non-object error - davy_yg - 04-28-2018 I finally find the answer to this one! Thanks. <img src="<?php echo base_url('/uploads/'.$file_name); ?>"> |