I am having problems with some code. I have 2 servers. Server 1 and Server 2. My website (gallery with thousands of pics) is being hosted on Server 1 and I want all images to be hosted on Server 2.
I already copied all images to the second server and edited my parameters so that my website gets all images from Server 2.
The problem is that when I upload new content, all images get uploaded to Server 1 instead of Server 2 which means I would need to copy everything every time which is a lot. I need to edit the following code so it will upload to Server 2.
<?php
namespace AppBundle\Provider;
use AppBundle\Entity\Item\Item;
class ImageUploadPathProvider
{
const SERVER_IMAGE_ROOT = '/home/DIRECTORY1/DIRECTORY2';
public function getItemOriginalPath(Item $item)
{
return sprintf(
'%s/images/%s/original/%s',
self::SERVER_IMAGE_ROOT,
$item->getGallery()->getDirectory(),
$item->getFilename()
);
}
/**
* @param Item $item
*
* @return string
*/
public function getItemThumbnailPath(Item $item)
{
return sprintf(
'%s/images/%s/thumbnail/%s',
self::SERVER_IMAGE_ROOT,
$item->getGallery()->getDirectory(),
$item->getFilename()
);
}
}