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?

  • 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 Jul 10 '13 at 13:34
  • But the hook is really fired when I am displayingf private file on page. – tomas.teicher Jul 29 '13 at 8:00
  • What leads you to believe that? (it isn't by the way :) – Clive Jul 29 '13 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. – tomas.teicher Jul 29 '13 at 8:37
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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