Using absolute path for fopen and mkdir - HOW?

Discussion in 'PHP' started by j0563, Dec 15, 2010.

  1. #1
    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);	
    
    
    PHP:
    This is working, but I need to do something like:

    
    $path = "http://www.mydomain.com/logs/".date("Y")."/".date("m"); 
    
    PHP:
    ANY help would be greatly appreciated!!
     
    j0563, Dec 15, 2010 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    i think that you really need to specify the path... you cannot access the raw file or the dir if you are using http://, clarify your thoughts on using http or https, its a request to the server, and gives you a html response. it will not show up like you opened an windows explorer or what ever. all http/s are CLIENT response. you can use it under.
     
    bartolay13, Dec 15, 2010 IP
  3. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #3
    you can not use fwrite with an URL path "http://xxx.com/file.php" you can use fwrite with absolute physical path of the file .. e.g. "/home/www/file.php" or relative path to the script like "../file.php".

    If you would able to do what you want to do.. imagine that everybody could alter everybody's files in the world... which is not normal.

    I hope this helps
     
    drctaccess, Dec 16, 2010 IP
  4. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #4
    You could try it this way.

    $path = dirname(__FILE__) . '/logs/".date("Y")."/".date("m");
    PHP:
     
    MyVodaFone, Dec 16, 2010 IP