Search code examples
cakephpdnssharingsubdomain

Sharing image folder between two domains cakephp


I have a website and a sub-domain that allows users to upload images to their account, the two domains are cakephp applications that share the same CakeLib but different apps dir. I want to be able to access images uploaded from either domains from the other one (e.g. if a user goes on the sub-domain and uploads an image, I should be able to access the same image from the parent domain and vise-versal).

Please note, accessing this images is done strictly in the views. I'll appreciate any suggestions.

Thanks


Solution

  • $this->Html->image('http://subdomain.example.com/image.png');
    

    Something like the above? :o, you could extend your helper as well:

    class MyAppHelper extends AppHelper {
        public $helpers = array('Html');
    
        public function subdImage($path) {
            return $this->Html->image('http://subdomain.example.com/' . $path);
        }
    }
    

    and call it from your view like:

    $this->MyApp->subdImage('image.png');