sharing folders between subdomains

HI, I have two subdomains and I would like to share a linked folder between them the question is I am at a loss as to how to do it

my code look like this
[php]
upload_Image($_FILES[‘main_image’][‘tmp_name’], $member_id,$profile_image,“upload/member”);
upload_Image($_FILES[‘extra_image1’][‘tmp_name’], $member_id,$extra_image1,“upload/member”);
upload_Image($_FILES[‘extra_image2’][‘tmp_name’], $member_id,$extra_image2,“upload/member”);
upload_Image($_FILES[‘extra_image3’][‘tmp_name’], $member_id,$extra_image3,“upload/member”);
[/php]

call back for the images are

<a href="upload/member/<?=$Member_Info['id']?>/large/<?=$Member_Info['profile_image']?>" class="highslide" onclick="return hs.expand(this)"><img src="upload/member/<?=$Member_Info['id']?>/<?=$Member_Info['profile_image']?>" alt="<?=cleanOutput($Member_Info['firstname'])?>"  /></a>

now my two domains are for example:

sub1.mydomain.com
sub2.mydomain.com

and the folder to share is

mydomain.com/upload

how to I alter my script to use the shared folder instead of

sub1.mydomain/upload or
sub2.mydomain/upload

and alter my call back code

the ftp tree would be

public_html/upload
public_html/sub1
Public_html?sub2

any help would really be appreciated

thank you

Can you just symlink the folder?

I’ve never even heard of symlink.

I’m totally new to coding and just learning as I go, I have ideas of what I want to do then I search how to do it and impliment it. Only not found an answer for this.

But I will look at symlinking could be useful, but knowing how to access below my subdomain into my main simian would be useful, I know I can use full path name to do it, but that would mean allowing hotlinking I think.

Google “symbolic link”

If you have SSH access it would be done like this:

ln -s /path/to/public_html/upload/ /path/to/public_html/sub1/upload
ln -s /path/to/public_html/upload/ /path/to/public_html/sub2/upload

Then /sub1/upload and /sub2/upload are simply references to the original /upload folder

If you don’t have access, ask your host

Thank you, I will look into that.

Of course, you could also specify the full path to the upload folder. The only difference is that sub1.mydomain/upload would not exist. I’m not really sure how you want this to work.

I don’t want either upload folder in the subdomains to exist instead preferring one single upload folder for all 3 domains to accessthe main domain and the two subdomains.

So you just need to specify the full path to that upload folder.

OK, thank you.

I don’t have access to SSH I’ve Googled and tried a cron job trick, didn’t seem to work.

So I went back to my original idea of using PHP

I tried this.

[php] $srcDir = ‘my source path’; $destDir = ‘my destination path’;

if (file_exists($destDir))
{ if (is_dir($destDir))
{ if (is_writable($destDir))
{ if ($handle = opendir($srcDir))
{ while (false !== ($file = readdir($handle)))
{ if (is_file($srcDir . ‘/’ . $file))
{ rename($srcDir . ‘/’ . $file, $destDir . ‘/’ . $file); } } closedir($handle); }
else { echo “$srcDir could not be opened.\n”; } }
else { echo “$destDir is not writable!\n”; } }
else { echo “$destDir is not a directory!\n”; } }
else { echo “$destDir does not exist\n”; }

[/php]

Although I get no errors I also don’t see any folders being moved from src. To dest.

I also tried

[php] <?php $file = ‘my source path’; $newfile = ‘my destination path’;

if (!copy($file, $newfile)) { echo “failed to copy $file…\n”; } ?> [/php]

Again no errors, but no movement.

My files tree is*

  • donates user id with in SQL

Public_HTML/UK/upload/member//user.jpg ( UK.mydomain.com a subdomain)
Public_HTML/US/upload/member/
/user.jpg ( US.mydomain.com a subdomain)

I then want them pooled together in so I can call them on a joint home page.

Public_HTML/upload/member/*/user.jpg ( www.mydomain.com a maindomain)

The script coder for the site only allows for root install and not in sub folders hence the quirky work around , I’m clearly filling in something wrong in the PHP code as it should work theoretically

Thank you for your patience

Maybe I’m missing something. If you specify the full path to the original upload folder there is no need for you to rename() files.

The content …

The users upload content to their perspective regioned sites as denoted by the subdomain

But as my templates are looking at main domain folder those images don’t spear on the website

Both sites use the same SQL database if I left the upload folders to be looked at the way they were set up by default. Then user images created on the UK site show as errors on the US site when viewing profiles and vice a versa

By having the content moved to the main site both sites will shoe content with no errors.

My host company said the symlink. Can’t be dine as the folders already exist. Which I find confusing my understanding was they where supposed to exist.

My only option now is to use PHP to copy or move the contents of the two sub folders to the main folder by way of a timed running of the php script.

Having explained my reasoning to my host company they implimemted the SSH setting for me. Thank you very much

Now to fix my town tables

I maybe back …

Thank you for excellent advice

Sponsor our Newsletter | Privacy Policy | Terms of Service