1
votes

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

2

2 Answers

0
votes
$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');
0
votes

Simply symlink the folder. I would make my upload path configurable and point it to /home/www-data/images for example and symlink it to both apps like /var/www/app1/webroot/img and /var/www/app2/webroot/img. No code needed at all. Symlinking works also on windows.