I would add to Simon Groenewolt comment-answer, is that you should start from checking if PHP can really write in the path you want, by using is_writable
function:
Example:
$filename = 'test.txt';
if (is_writable($filename))
{
echo 'The file is writable';
}
else
{
echo 'The file is not writable';
}
Just set proper permission, as stated by Log1c on the directory you're trying to write in, by running chmod a+w /yourpath/yourdir
, which is 666
, meaning read and write for all, a user
, an owner
and the world
.
is_writable() Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.
Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody'). Safe mode limitations are not taken into account.
EDIT 1:
Make sure that PHP open_basedir
setting, is also set to access /tmp
. You could just disable it for testing purposes, to see what you get. Try checking what is open_basedir
settings are set to, by running:
echo ini_get('open_basedir');