...

View Full Version : Problem on FILE OPERATOINS ON LINUX O/S( PLZ GIVE REPLY )



lampbabu
02-14-2006, 09:43 AM
i got a problem when i am creating the file through PHP Program in LINUX O/S Machine..the code is as shown below..
<?php
$phpfile="demo_php.php";
$phpfile=$_SERVER['DOCUMENT_ROOT'].$phpfile;
$content="ABCDEF";
$handle=fopen($phpfile,"w")
/*
assume phpfile not exist ,the create the file and open that file in the write mode.
*/
fwrite($handle,$content);

?>

error is : No Permission to create the file....


i set the permissions 0777 to that folder

firepages
02-14-2006, 01:57 PM
You are trying to create.. e.g. /home/usernamedemo_php.php
e.g. you are missing a slash.


<?php
$phpfile = $_SERVER['DOCUMENT_ROOT'].'/'.$phpfile;
?>

Velox Letum
02-14-2006, 08:25 PM
Also, shouldn't the mode be "w+" to create the file if it doesn't exist?

firepages
02-14-2006, 10:33 PM
w+ opens for reading and writing, w is just for write, either should work



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum