Jump to content

Can't write to file


arkum

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.