'Accessing Different Image Source Folder Codeigniter

Hello I'm learning to use CodeIgniter 3. I'm having trouble accessing image sources from a different CodeIgniter Applications folder. In this case I have a domain and a sub-domain. For example, my domain name is (a.com), and subdomain (sub.a.com)

1. (sub.a.com) it has a feature to upload images that will be stored in a folder (assets/images):

  • application
  • assets (images)
  • system

2. (a.com), have a folder structure like this:

  • application
  • system

On (sub.a.com), I use a query like this to display the images:

<?php foreach ($images as $img) { ?>
  <img src="<?php echo base_url('assets/images/').$img->image;?>">
<?php } ?>

The problem is, is it possible (a.com) to access the images in the (sub.a.com/assets/images) folder, by using 1 database (tb_images)?

Because I was required to have 2 different CodeIgniter folders. Can you help me, by providing a reference? Thank you very much.



Solution 1:[1]

You can use it like this in you a.com application:

<?php foreach ($images as $img) { ?>
  <img src="https://sub.a.com/assets/images/<?php echo $img->image; ?>">
<?php } ?>

That is, rather than using the base_url(), use the full URL there. Or you can define the https://sub.a.com/assets/images/ in a global variable or create a helper function that appends this part, when you echo the image url

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1