Does not Php read a specific directory?
source link: https://www.codesd.com/item/does-not-php-read-a-specific-directory.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Does not Php read a specific directory?
Something strange happens with my centos server. I have an asterisk server and I need to access to the recording dir. But it is impossible.
The dir /var/spool is unreadable. I can access with ssh with root and apache users, but from php it is impossible.
I don't know why!! This dir and /var/test/ has the same permissions (owner, group, chmod 755, ALL).
I use this php code:
I try to use exec function (works from another dirs), is_readable, file_get_contents but nothing :(
function wav_callid($id) {
$id = (int) $id;
$filename = 'cid'.$id.'.wav';
$path = '/var/spool/asterisk/monitor/' . $filename;
$tmp_path = '/tmp/' . $this->global_model->generate_random_hash();
exec("cp '$path' '$tmp_path'");
var_dump(is_readable('/var/spool')); // RETURN FALSE
var_dump(scandir('/var/spool')); // RETURN FALSE
var_dump(file_get_contents($path)); // RETURN FALSE
var_dump(is_readable('/var/test')); // RETURN TRUE
var_dump(scandir('/var/test')); // RETURN ARRAY
/*header('Content-Description: File Transfer');
header('Content-Type: audio/x-wav');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo file_get_contents($tmp_path);*/
}
What do I have to do?
Sorry for my bad english.
Thanks
Save your project into /var/www/html directory.Then change permission.Or create project foldar symbolic link into /var/www/html directory.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK