Search code examples
phpfilepathabsolute-path

Get an absolute file path


How to get a absolute file path php

I have a folder abc and xyz.

I am including the file a.php of abc in xyz folder using Ajax request by giving relative path which is like:

../a.php

The file a.php contains some actions which are done using Ajax request.

In xyz folder i want to perform same actions which are perform in abc folder, but when i try to perform those actions it is searching for files in xyz folder instead of abc, so the actions which i want to perform in xyz are not working.

Please help me how to do this.

Updated code:

$(function(){
    $.ajax({
        type:"POST",
        url: "../xyz/a.php",
        data: {
            "Id": '<?php echo $_GET['Id'];?>'
        },
        success: function(data){
            $("#divId").html(data);
        }
    }); 
});

Solution

  • In Ajax request i have changed url like this

    url: location.protocol + "//" + location.host + "projectname/foldername/filename.php"
    

    Then it worked perfectly