Hi ....

I am building a system that runs on a server with CentOS Linux, the site is located in the folder: / var / www / html / panel

the problem is I have to access a file that is in the folder: /var/asterisk/monitor, so the file is out of the $DOC_ROOT, and I provide a link for downloading this file.

I simply can not access. if using the variable $ _SERVER [ 'DOCUMENT_ROOT'] I can go to the root of the apache server that is /var/www, but I can not in any way to access something external to it ...

I tried to turn back the directory like this ..
"../../../var/asterisk/monitor, " but I can not, is automatically inserted into the start of the link the server address http://201.25.265.56/ .... then any address I put the link is more or less well

"http://201.25.265.56../../../var/spool/asterisk/monitor"

I tried to put the full path too .. like /var/asterisk/monitor .. But so far without success ...

I would like to help a .. a light ... I search in a forum but without sucess ....

thanks

"excuse my poor english, cause in my country we speak portuguese"

    AnarcoDioniso wrote:

    I tried to put the full path too .. like /var/asterisk/monitor .. But so far without success ...

    Well, that would be the way to do it (use a file path and not a URL), so if you don't have any success what happens instead? Do you get any error messages? Can we see the code you're trying to use?

      Hello, I resolve like this : clicking on the link the user is taken to another page, and is passed by the URL variable with the ID desired .. so

      ###
      if ($_GET[id])
      {

      $value_de= $_GET[id];
      $dl_full = "/var/spool/asterisk/monitor"."/".$value_de;
      $dl_name=$value_de;

      if (!file_exists($dl_full))
      {
      echo gettext("ERROR: Cannot download file ".$dl_full.", it does not exist.<br>");
      exit();
      }

      header("Content-Type: application/octet-stream");
      header("Content-Disposition: attachment; filename=$dl_name");
      header("Content-Length: ".filesize($dl_full));
      header("Accept-Ranges: bytes");
      header("Pragma: no-cache");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Content-transfer-encoding: binary");

      readfile($dl_full);
      exit();
      }
      ###

      This works great !!
      But i still Having troubles when i try to delete the archive...in the system the user haves the option to delete the archive

      I tried to simply replace the function readfile () above by unlink () but did not work ...

      How should I proceed to get to a unlink ()? which would require putting headers?

      I've tried to create an Apache Alias of the directory, called sound, using the alias i can acess directily the directory and i can open files too. but.. still doesnt working to delete the archive.

      like this

      ####
      Using apache alias
      ###

      //http://201.88.53.234/sound/
      // THIS IS THE APACHE ALIAS, I HAVE DIRECT ACCESS TO THE DIRECTORY #/VAR/SPOOL/ASTERISK/MONITOR#

      if(isset($GET['id'])):
      $del_id = $
      GET['id'].".gsm";
      $del_path = "http://201.88.53.234/sound/".$del_id;
      endif;

      //Trigger
      if(isset($POST['MM_del']) && $POST['MM_del'] == "MM_del"):

      if(is_file($del_path)):

      unlink($del_path) or die("Não foi possível excluir o arquivo !!!");

      endif;

      header("Location:painel.php?inc=gerencia_conta&reset=0&pg=0&sort=starttime&sentido=ASC");

      endif;
      #####

      i receive no error messages, and the DIE() function isn't triggered, it seems the unlink() function run ok, but dont runs cause the archive still there.

      Thanks by the help

        Write a Reply...