0

I know by default you can not use an absolute path when using fopen and mkdir, but in my case I really need to specify the exact location of the files/directories.

I KNOW there must be some workaround way to do this... does anyone know how?

For example, here is what I am using now:

$path = "../../logs/".date("Y")."/".date("m"); 
$filename = date("M.d.Y").".txt";

	$openfile = fopen($path."/".$filename, 'a');
	fwrite($openfile, $logcontent);
	fclose($openfile);

This is working, but I need to do something like:

$path = "http://www.mydomain.com/logs/".date("Y")."/".date("m");

ANY help would be greatly appreciated!!

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by ghazanfar381
0

If you don't know the path to your document root you can use $_SERVER['DOCUMENT_ROOT']

$path = $_SERVER['DOCUMENT_ROOT']."/logs/".date("Y")."/".date("m");

NOTE: DOCUMENT_ROOT is blank on an IIS (Windows) web server.

0

I know by default you can not use an absolute path when using fopen and mkdir, but in my case I really need to specify the exact location of the files/directories.

I KNOW there must be some workaround way to do this... does anyone know how?

For example, here is what I am using now:

$path = "../../logs/".date("Y")."/".date("m"); 
$filename = date("M.d.Y").".txt";

	$openfile = fopen($path."/".$filename, 'a');
	fwrite($openfile, $logcontent);
	fclose($openfile);

This is working, but I need to do something like:

$path = "http://www.mydomain.com/logs/".date("Y")."/".date("m");

ANY help would be greatly appreciated!!

it seams that you want to rewrite url. isn't it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.