I want to use a subdomain to upload image to main domain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

I want to use a subdomain to upload image to main domain

Post by simonmlewis »

Code: Select all

$target = $_SERVER['DOCUMENT_ROOT']."/images/uploads/";
I'm using this script to tell a small upload script where to send a file.
Under "httpdocs" this works. But under "demosite.site.com" it doesn't... becuase I want it to upload it to the main httpdocs folder, where I will reference to it from the main site too.

I thought I could do it like this:

Code: Select all

$target ="http://www.site.com/images/uploads/";
But that doesn't work at all. Should it? Or is there a better way of using the first version, but with an alternation??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: I want to use a subdomain to upload image to main domain

Post by Celauran »

You need to specify the file path, not the URL. How to accomplish that really depends on where your subdomain lives relative to your parent domain. Certainly listing the path as a configuration setting will work, though it's not terribly robust/portable.
Post Reply