Get URL from the page that called the file with jQuery . load()

Asked

Viewed 124 times

0

I have a PHP function:

if( !function_exists('site_url_full') ) {
    function site_url_full() {
        $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
        $PHPSELF = $_SERVER['PHP_SELF'];
        $path = pathinfo( $PHPSELF );
        $diretorio = $path['dirname'];
        $diretorio = "";
        if(is_dir(PATH)) {
            $url = $protocol . $_SERVER['HTTP_HOST'] . $diretorio;
        } else {
            $url = $protocol . $_SERVER['HTTP_HOST'];
        }
        return $url . $_SERVER['REQUEST_URI'];
    }
}

Use to 'grab' the full page URL but when it is called inside a file it is called in an event with jQuery . load(); the URL taken is that of the file, I don’t know how to call the URL that called the file, and I need this function to run inside the uploaded file, is there any way to get the main URL from the uploaded file? Because the URL is included within an input*Hidden of the requested file.

1 answer

2


Utilize $_SERVER["HTTP_REFERER"];. It will return the URL of the page that called AJAX, not the requested PHP page.

  • Thanks for that rs =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.