Forum Moderators: coopster
here's my code
$fp = fopen("$file_name ","a+");
if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file
}
It could be a permissions issue, so try the chmod [us.php.net] function after writing the file:
fclose($fp); // Close the file
@chmod($csvData,0644);
dc
The weird thing is that if i try to chmod or chgrp just after the file has been created it returns an error saying the file can't be found even when the file exists and the path is correct. I did a recursive chmod on the directory...changed everything to 0777 however the problem still remains...a web or ftp user cannot view/edit/delete the generated file even under 777 permissions...
...a web or ftp user cannot view/edit/delete the generated file even under 777 permissions...
If the file did have 0777 perms then everyone whould be able to view the file - so it looks like your recursive chmod failed on this file. An FTP user is unlikely to have enough perms by default, unless your PHP script has changed them. The FTP user is usually different to the user that PHP runs under.
Have you tried clearing the umask before creating your file? Something like:
$old_umask = umask(0);
$fp = fopen($file_name,'wb');
umask($old_umask);
The morale of the story....be very careful when creating files in a Linux/Unix environment
$fp = fopen("$file_name ","a+");
if($fp){