Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7440121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:48:12+00:00 2026-05-29T10:48:12+00:00

I am using CodeIgniter 2.1.0 and MySQL database. I have uploaded an image through

  • 0

I am using CodeIgniter 2.1.0 and MySQL database. I have uploaded an image through a form and successfully stored it in a uploads directory and I have also successfully stored the full path of the image in my database. but i am having problem with showing the image by calling the full path from my database.

Here is my code for the upload:

$image_path = realpath(APPPATH . '../uploads');

$config = array(
    'allowed_types' => 'jpeg|png|gif|jpg', 
    'upload_path' => $image_path, 
    'max_size' => 2097152, 
    'overwrite' => TRUE, 
    'file_name' => '_' . $i . '_'
);

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

When I am storing the full path of the image in my database, it looks something like this

C:/wamp/www/my_project/uploads/_1_.jpg

If i try

<img src="<?php echo $data['screenshot'];?>" />
//($data['screenshot'] refers to the image location retrieved from database)

this in my view file, no image is displayed. What am I doing wrong? Please someone tell me. What is the standard procedure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:48:13+00:00Added an answer on May 29, 2026 at 10:48 am

    In your database, if i have understood correctly, you’re storing the image as C:/wamp/www/my_project/uploads/_1_.jpg

    So when you’re echoing out the image path the img src attribute, you will have

    which won’t work as this as local path on your machine. I won’t have that image on my file system. The image needs to be accessible on the webserver. (like your index.php file)

    So you need the store the image as either this:

    uploads/_1_.jpg

    and then do <img src="<?php echo $data['screenshot'];?>" />

    Or store the image as:

    _1_.jpg and
    and then do

    <img src="<?php echo sprintf("uploads/%s", $data['screenshot']);?>" />

    EDIT: To be clear: Where you’re storing it is correct. But, you don’t need the full path in the DB, you just need the web server path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter with CodeIgniter sessions that are stored in a MySQL database. I
i am using codeigniter 2.1.0 and mysql database. in my admin panel i have
I'm using CodeIgniter's Active Record class to query the MySQL database. I need to
I am using Codeigniter framework and I have a form with input fields. When
I would like to store images in my mySQL database using the CodeIgniter PHP
I want to insert current time in database using mySQL function NOW() in Codeigniter's
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I'm using apache, php, mysql and code igniter and I have a database set
I have been working an application using PHP & MySql on Codeigniter framework. It
I am using MySQL fulltext and PHP (codeigniter) to search a database containing RSS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.