0

I successfully uploaded the image to my upload directory. This is structure

public_html -> uploads -> image.gif

Now the path I have stored in DB record is:

./uploads/image.gif

yet when I do this:

echo "<img src='{$imagePath}' alt='some_text'>";

It still doesn't show anything. The image path content is ./uploads/image.gif .

I am trying to load the image in a view which is located in the following:

public_html->application->views->new->someView.php

Help will be really appreciated.

1
  • If you store the images int the same folder you don't need to save the path, just save the image name. Try to print the full image path with http:// etc. Commented Oct 18, 2013 at 17:02

3 Answers 3

1

try this <img src="<?php echo base_url(); ?>uploads/image.gif" />

Sign up to request clarification or add additional context in comments.

2 Comments

@spacemonkey store the image path in the database <img src="localhost/public_html/uploads/image.gif" /> and echo the image in the view folder <?php echo($row->image);?> using a loop.you have to write your database logic in model.
@spacemonkey you can check this also for better understanding pastebin.com/VcqACSJH hope so, this will help.
1

Thanks all for the answers shared. Unfortunately, the answer was totally different. the .htaccess file in the root of my domain disabled routing to the folder uploads. Hence with modification to that file (to ignore the uploads) folder, things worked well and images loaded.

Now this is a note for anyone who may face this problem in the future:

If you can't access the folder where you uploaded items reside, check the expression in the .htaccess file and if the files hosting the uploaded items is within the application folder of CI, then check .htaccess and routes.php. There's a good chance your answer is there.

hope this helps whoever needs it in the future.

Comments

0

What about this one

$path= site_url().str_replace("./","",$imagePath);
echo "<img src='{$path}' alt='some_text'>";

or

$path= base_url().str_replace("./","",$imagePath);
echo "<img src='{$path}' alt='some_text'>";

1 Comment

that still didn't work. Can it be something with permissions? I have it set to 777

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.