Wordpress - Upload images to remote server

I have just built a plugin that does this. It is not perfect but it do its job.

You can find it in my Github: https://github.com/pontusab/wp-ftp-media-library

So you need to change some things within the file on the row 28:

/**
     * Change this to match your server
     * You only need to change the those with (*)
     * If marked with (-) its optional 
     */

    $settings = array(
        'host'    =>    'ip or hostname',           // * the ftp-server hostname
        'user'    =>    'username',                 // * ftp-user
        'pass'    =>    'password',                 // * ftp-password
        'cdn'     =>    'cdn.example.com',          // * This have to be a pointed domain or subdomain to the root of the uploads
        'path'    =>    '/',                        // - ftp-path, default is root (/). Change here and add the dir on the ftp-server,
        'base'    =>    $upload_dir['basedir']      // Basedir on local 
    );

What this plugin does is, it changes the upload structur from /year/month to only upload on the local machine in our case Server A. Then it uses php to connect to the ftp via: ftp_connect. The function fires when wp_generate_attachment_metadata runs. It then run a check in the upload folder to see if there areu any images, if so it will upload them all to the ftp-server via ftp_put. When the upload is completed the files will be removed from the local machine using the function unlink.

Then the plugin changes the url of the images to the "public" ip or hostname pointed to the ftp-server. I suggest using something like static.mydomain.com or cdn.mydomai.com. They need to be pointed to the ftp-server (Server B) this enables you to load the images from the ftp-server.

As the other members say you shouldent use an ftp-server for this, its better with an real cdn, Mounted by fuse or something like Amazon S3.