You are not logged in.
Pages: 1
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
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
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
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
Pages: 1