Uploaded files from one domain to another (same database)

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 28, 2010   (RSS)

Re: [rjbathgate] Uploaded files from one domain to another (same database)

By Chris - October 27, 2010

Hi rjbathgate,

I think the simplest solution is to only use CMS Builder's admin panel on one domain, then hardcode that domain into the URLs for uploads on all other domains.

Does that help?
All the best,
Chris

Re: [chris] Uploaded files from one domain to another (same database)

Hey Chris,

That was my original thought, but we really need to offer domaintwo.com/CMSB too, and also each domain's front end has a function to upload files too (i.e. member's area).

So user can go to domaintwo.com/members and upload a file. This upload record goes to the one master database, and the file is physically added to /uploads/ of domaintwo.com

But then domainone.com will have the upload record in the mySQL, but won't have /uploads/image on it's server.

Hmmz, thinking only way is to code each code of img display to check each domain for an image (if file_exists, then try next domain (or get domain image was uploaded from pushed to mySQL too)), or try and get domaintwo.com/members to upload the file to domainone.com/uploads.

I'll give it a play, unless you have another masterous easy solution?!

Cheers

Re: [rjbathgate] Uploaded files from one domain to another (same database)

By Chris - October 28, 2010

Hi rjbathgate,

Here's a sneaky solution for you: if your upload URLs are different on each site, you could have your front-end PHP code examine the URL and prefix a host depending on what the path is.

For example, domainone could use /cmsAdmin/uploads/domainone/ for uploads, while domaintwo could use /cmsAdmin/uploads/domaintwo/. Your <img/> display code would then search the image's URL for "domainone" and "domaintwo" and prefix either http://domainone.com/ or http://domaintwo.com/

Make sense?
All the best,
Chris

Re: [chris] Uploaded files from one domain to another (same database)

yeah, thats a nice idea, thanks. Saves running an if file_exists over and over again.

Thanks for the idea!