Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-08-21 08:54:23

MySchizoBuddy
Xinha Community Member
Registered: 2005-08-17
Posts: 22

Image path & url

Simple question based on my directory structure below

www
---blog
------uploads //image folder

my image path = www/blog/uploads/
my image url = http://myschizobuddy.com/uploads/

can anyone give me a php script to generate these paths.

Offline

#2 2005-08-21 13:38:41

kimss
Xinha Pro
From: Sweden
Registered: 2005-04-05
Posts: 99
Website

Re: Image path & url

Im pretty sure your server path is not /www/blog/uploads/ unless its your own private server, you should look at the PHP value :

$_SERVER["DOCUMENT_ROOT"]

This will default to the "...../www" folder from the server root. So answering your first question :

$serverpath = $_SERVER["DOCUMENT_ROOT"]; if(ereg("/$",$serverpath)) $serverpath = ereg_replace("/$","",$serverpath);
$image_path = $serverpath . '/blog/uploads';

If you wonder of my serverpath ereg stuff this is to be sure we are not on some exotic server which has / in the end, this way we are quite sure if it ends or not with a /.

Your second question you dont need PHP for, or you could however :

// Your config line :
$subdirectory = '/blog/uploads';

$serverpath = $_SERVER["DOCUMENT_ROOT"]; if(ereg("/$",$serverpath)) $serverpath = ereg_replace("/$","",$serverpath);
$image_path = $serverpath . $subdirectory;
$image_url = 'http://' . $_SERVER["HTTP_HOST"] . $subdirectory;

What I dont understand from your post however is why you have /blog/uploads on the first and only /uploads on the second, I guess its a typo from you.

Offline

#3 2005-08-21 16:01:23

MySchizoBuddy
Xinha Community Member
Registered: 2005-08-17
Posts: 22

Re: Image path & url

Yeah i have shared hosting.
actually my domain points to the blog folder. and not the www folder. once i have a website i will then point it back to www folder insead of my blog folder.

Offline

#4 2005-08-21 16:29:48

kimss
Xinha Pro
From: Sweden
Registered: 2005-04-05
Posts: 99
Website

Re: Image path & url

If your domain points to the blog folder than probably the $_SERVER["DOCUMENT_ROOT"] will also be up to the blog folder, so from my above code you just change this :

$subdirectory = '/blog/uploads';

to this :

$subdirectory = '/uploads';

Offline

Board footer

Powered by FluxBB