dsvyc66464 2019-07-01 16:24
浏览 30

将图像上传到第二台服务器(基于symfony的网站)

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()
        );
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀