I have a site in my redhat system.In this site i run some php scripts from command line like:
I use this to manage to have the permissions for viewing the contents of a directory that is out of apache tree.
So. when i try to download a file from the site i take a page with the contents of the file instead of the prompt "save file as".
the code i use is:
file download:
#!/usr/bin/php
<?php
$file=$argv[1];
$name=$argv[2];
$fp=fopen($file, "r");
header("content-type: attachment; name=\"$name\"");
header("content-disposition: filename=\"$name\"");
header("content-length: ".filesize($fp));
fpassthru($fp);
exit;
?>
and i call it from the index as:
system("/usr/bin/sudo -u $user_name php ./commands/download $file $name");
I'm thinking that the problem is that i run the script from command line because i try to run it including the php code in my index and it runs sussesfully if the file has at least permisission mask r--r--r--.
Any help please?