Secure permissions to enable file writing in directory
Posted: Sun Feb 06, 2011 6:16 am
I wanted to check about the security of changing permissions to enable a php script to write to a directory on the server. This is the php code :
I find I have to set the permissions of the /text/ directory to at least 767 to enable this, but feel unsure if that is safe.
Only the php script needs access to these text files, so would it be safer to write them in a directory outside of public_html?
Code: Select all
//get html file and save on server as text
$ch = curl_init("http://site.com/file.html");
$fp = fopen("/home/username/public_html/text/file.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);Only the php script needs access to these text files, so would it be safer to write them in a directory outside of public_html?