How to hide path location in drupal 7? How to hide path file in drupal? Now it looks like this:

http://localhost/drupal/sites/default/files/document.pdf


I want to change to look something like this:

http://localhost/drupal/media/view.php?id=6445
It can be done by implementing custom menu callback

/**
 * Implementation of hook_menu()
 */
 function mymodule_menu() {
   $items['media/view/%file'] = array(
     'page callback' =&gt; 'mymodule_download_file',
     'page arguments' =&gt; array(2),
     'access arguments' =&gt; array('access content'),
     'type' =&gt; MENU_CALLBACK,
   );
   return $items;
}

/**
 * Page callback for a file to download
 */
 function mymodule_download_file($file) {
   if($file) {
    file_transfer($file-&gt;uri, array('Content-disposition', 'attachment; filename='.$file-&gt;filename));
   }
   else {
    return drupal_access_denied();
   }
 }