arkum Posted December 15, 2006 Share Posted December 15, 2006 Hi there,My first post so treat me gentle...I'm trying to use the following code to write to a .txt file. I'm running a server on my mac, and I've gone through every folder from Sites down to the .txt file and set all group permissions to read/write, but when I run the script (from a flash .swf), it returns the $msg as "File is not writable";<?php$myFileName=$_POST["fileName"];$content=$_POST["myContent"];$targetFile;$msg; [code]if(is_writable($myFileName)) { $msg = $myFileName.'isWritable'; if (!$targetFile = fopen($myFileName, 'w')){ $msg .= "File can't be opened"; }else{ $msg .='isOpenable'; } if(fwrite($targetFile, $content) === FALSE){ $msg .= "Can't write to file"; }else{ $msg .= 'isWritten'; } }else{ $msg = $myFileName.'File is not writable';}echo "&msg=$msg";?> [/code]No idea what else to do. Any help greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/30754-cant-write-to-file/ Share on other sites More sharing options...
craygo Posted December 15, 2006 Share Posted December 15, 2006 I am not familiar with a mac OS so here are some general checksIs the folder in your web root or outside of it??If outside does the permissions include the account for the web server??Also make sure nothing else has the file open.Ray Link to comment https://forums.phpfreaks.com/topic/30754-cant-write-to-file/#findComment-141747 Share on other sites More sharing options...
arkum Posted December 15, 2006 Author Share Posted December 15, 2006 Hi Ray,The file is within the root folder. How do I change the permissions of the web server account?The files are all in a root folder linked to a subdomain "http://mysubdomain.localhost" I am using an absoulute URL to call the php file, but a relative one for the file it is supposed to write to. Link to comment https://forums.phpfreaks.com/topic/30754-cant-write-to-file/#findComment-141762 Share on other sites More sharing options...
freeloader Posted December 15, 2006 Share Posted December 15, 2006 Normally, you should've full permissions when u run a home server. What server software are you using? Link to comment https://forums.phpfreaks.com/topic/30754-cant-write-to-file/#findComment-141768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.