zeektechnet Posted October 23, 2007 Share Posted October 23, 2007 Hello, I have an issue on a script that works beautifully except for when I am wanting to save to a file. I have a domain setup in cPanel where the web files are in the normal public_html folder. Then I have setup a subdir (../edit) with a script that allows editing of .HTM files through the SPAW editor. I have setup a form to submit the changes to a variable and then I want to save the variables values to the selected file. Below is my code. What happens is that, even with file permissions at '0777', the file will not write and will not open. If permissions are set at '0776', the error returns that the file is not writable. I am thinking that this is an ownership issue and if so, is there any way around this? Do I have to implement a temporary file structure? $fileDir = "../"; if ((isset($_POST['pageToEdit'])) && ($_POST['pageToEdit'] != NULL) && ($_POST['pageToEdit'] != '') && ($_POST['pageToEdit'] != ' ') && (isset($_POST['fileSelect'])) && ($_POST['fileSelect'] != NULL) && ($_POST['fileSelect'] != '') && ($_POST['fileSelect'] != ' ')) { $fileToSave = $fileDir . $_POST['fileSelect']; echo "File to save set to '$fileToSave'. "; if (is_writable($fileToSave)) { $openFile = fopen($fileName, "w+"); if ($openFile) { echo $fileToSave . ' has been opened. '; } else { echo $fileToSave . ' was not able to be opened! '; } if (fwrite($fileToSave, $_POST['pageToEdit']) === FALSE) { echo "<p class=\"error\">Cannot write to file ($filename)</p>"; } else { echo "<p class=\"noError\">Updates successfully written to $fileToSave!</p>"; } } else { echo "<p class=\"error\">$fileToSave is not wriable or does not exist.</p>";} } else if (isset($_POST['pageToEdit'])) { echo "<p class=\"error\">Could not save the changes to $fileToSave!</p>"; } Quote Link to comment https://forums.phpfreaks.com/topic/74476-using-fwrite-on-a-cpanel-server/ Share on other sites More sharing options...
only one Posted October 23, 2007 Share Posted October 23, 2007 $openFile = fopen($fileToSave, "w+"); Quote Link to comment https://forums.phpfreaks.com/topic/74476-using-fwrite-on-a-cpanel-server/#findComment-376358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.