0

I have implemented hook_file_download function in my module. When I call function current_path in the body of this hook, it returns path of the file, not path of current URL in browser. The similar result I got when I try method request_path or variable $_SERVER['REQUEST_URI'].

My hook_file_download is called after I am programatically displaying image with function

<?php
function some_page_callback() {
// $args = ...some args
$output = theme('image_style', $args);
return $output;
}
?>

How to get path registered in hook_menu for "some_page_callback" in hook_file_download method?

4
  • That's the correct behaviour. If current_path() wasn't the URL of the file, then the file must never have been requested, and that hook would never have fired. When you request a private file the current URL must be the file's URL, by definition. It sounds like you're looking to track the page that originally contained a link to your file. That's going to be almost impossible to do reliably.
    – Clive
    Commented Jul 10, 2013 at 13:34
  • But the hook is really fired when I am displayingf private file on page. Commented Jul 29, 2013 at 8:00
  • What leads you to believe that? (it isn't by the way :)
    – Clive
    Commented Jul 29, 2013 at 8:03
  • I think Clive's comment could be considered as correct answer. Although it doesn't solve my problem checking access using hook_file_download based on HTML page, where the file link is placed. But it is another question. Commented Jul 29, 2013 at 8:37

1 Answer 1

1

That's the correct behaviour.

If current_path() wasn't the URL of the file, then the file must never have been requested, and that hook would never have fired.

When you request a private file the current URL must be the file's URL, by definition. It sounds like you're looking to track the page that originally contained a link to your file. That's going to be almost impossible to do reliably.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.