• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image not showing in codeigniter 4

#1
<img src="<?=WRITEPATH.$value->avatar?>">

this image not displaying

but when i open D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg link on browser image showing.

After i put directly link in img and not displaying 
<img src="D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg">

Please help ,
Reply

#2
(11-06-2019, 12:19 AM)durairaj Wrote: <img src="<?=WRITEPATH.$value->avatar?>">

this image not displaying

but when i open D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg link on browser image showing.

After i put directly link in img and not displaying 
<img src="D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg">

Please help ,

Hello try this I think it will help you get the image. It work for me
PHP Code:
<img src="<?php echo base_url('uploads/avatar/'.$value->avatar); ?>"

But I will prefer you use another location for you files since writable folder is temporal for files.
Use some thing like
PHP Code:
<img src="<?php echo base_url('.public/uploads/images/users/'.$user->avatar);?>"

Instead of saving to the writable folder.
I hope this will help you and others here
Visit Chivins.Com For Free Tutorial on Codeigniter
Reply

#3
All files in the "writable/uploads" folder should be temporary. Usually there is placed avatars user which only that uploaded on server, but still not typically recognized process and shifting in folder "public/assets", if anything you must use function
PHP Code:
<= base_url($value - >avatar)?>
I would change this world, but God doesn't give me the source.
Reply

#4
(11-06-2019, 12:19 AM)durairaj Wrote: <img src="<?=WRITEPATH.$value->avatar?>">

this image not displaying

but when i open D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg link on browser image showing.

After i put directly link in img and not displaying 
<img src="D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg">

Please help ,

This is not a valid URL as far as the browser is concerned when part of an HTML page D:\xampp\htdocs\apptsys\writable\uploads/avatar\avatar_1.jpg.

Also, if you're using the default configuration of CI and serving from the public folder as intended, the writable directory is not accessible from the web. You'll need to either save the files somewhere they're publicly available, or create a new route that acts as a proxy to the images. The second option isn't a bad way, since that allows you to build in other potential restrictions if needed, but also uses more server resources.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#5
I would hard a guess and think the image is being called from the public folder... If so and you really want to use the WRITEPATH folder then try using s relative path which should be converted to an URL:

<img src="../writable/uploads/avatar/avatar_1.jpg">

I will try it to make sure it works when I am back on the desktop.

As mentioned far better to group all callable files into a common folder:

/public_html/assets/
css/
img/
js/
svg/
download and make your system directory strict
Reply

#6
(11-06-2019, 06:40 PM)John_Betong Wrote: I would hard a guess and think the image is being called from the public folder... If so and you really want to use the WRITEPATH folder then try using s relative path which should be converted to an URL:

<img src="../writable/uploads/avatar/avatar_1.jpg">

I will try it to make sure it works when I am back on the desktop.

As mentioned far better to group all callable  files into a common folder:

/public_html/assets/
css/
img/
js/
svg/

This is not working..
Reply

#7
(11-06-2019, 09:54 PM)durairaj Wrote:
(11-06-2019, 06:40 PM)John_Betong Wrote: I would hard a guess and think the image is being called from the public folder... If so and you really want to use the WRITEPATH folder then try using s relative path which should be converted to an URL:

<img src="../writable/uploads/avatar/avatar_1.jpg">

I will try it to make sure it works when I am back on the desktop.

As mentioned far better to group all callable  files into a common folder:

/public_html/assets/
css/
img/
js/
svg/

This is not working..

It sort of works for me because I store an SVG image in the writable folder and echo the SVG file contents.

The IMG requires a valid URL and WRITEPATH is above the root and not accessible.

Use "Plan B" - store all images in /public_html/assets/imgs/ folder.
download and make your system directory strict
Reply

#8
This is not working ,i don't know how to store images in public folder, $avatar->move( base_url().'/public/assets/avatar', $name ); this popped with index.html not found on directory.
i'm not able to show uploaded images if someone has example pls let me know.thank you.
Reply

#9
Try this:
1. index.php -> echo $PATH = getcwd(); die;
2. make a note of the $PATH;
3. create this folder: $PATH .'\assets\avatar'
4. save this avatar file: $PATH .'\assets\avatar\avatar_1.jpg'
5. test: index.php -> echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';

Edit:
If that does not work and the image file is saved in the correct path then there is most likely to be a problem with .htaccess file. If so temporarily rename .htaccess file and try again.

Also in index.php temporarily add these lines:
<?php
declare(strict_types=1);
error_reporting(-1);
ini_set('display_errors', '1');

echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';
die;
download and make your system directory strict
Reply

#10
(11-06-2019, 11:30 PM)John_Betong Wrote: Try this:
1. index.php -> echo $PATH = getcwd(); die;
2. make a note of the $PATH;
3. create this folder: $PATH .'\assets\avatar'
4. save this avatar file: $PATH .'\assets\avatar\avatar_1.jpg'
5. test: index.php -> echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';

Edit:
If that does not work and the image file is saved in the correct path then there is most likely to be a problem with .htaccess file. If so temporarily rename .htaccess file and try again.

Also in index.php temporarily add these lines:
<?php
declare(strict_types=1);
error_reporting(-1);
ini_set('display_errors', '1');

echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';
die;
thanks man ,i will try

(11-07-2019, 12:23 AM)durairaj Wrote:
(11-06-2019, 11:30 PM)John_Betong Wrote: Try this:
1. index.php -> echo $PATH = getcwd(); die;
2. make a note of the $PATH;
3. create this folder: $PATH .'\assets\avatar'
4. save this avatar file: $PATH .'\assets\avatar\avatar_1.jpg'
5. test: index.php -> echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';

Edit:
If that does not work and the image file is saved in the correct path then there is most likely to be a problem with .htaccess file. If so temporarily rename .htaccess file and try again.

Also in index.php temporarily add these lines:
<?php
declare(strict_types=1);
error_reporting(-1);
ini_set('display_errors', '1');

echo '<img src="/assets/avatar/avatar_1.jpg" alt="#" width=333 height=333 >';
die;
thanks man ,i will try
thanks a lot. you helped me lot,no words to say thank you.it's working
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.