note 54623 rejected from function.touch by betz

From: Date: Sun, 10 Jul 2005 11:56:26 +0000
Subject: note 54623 rejected from function.touch by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-91735@lists.php.net to get a copy of this message
Note Submitter: din_marius at yahoo dot co dot uk ---- the script below is to create a file into a folder in two situations: - the folder exists, and then the scripts create only the file taking the name from the html form -the folder does`nt exists and then the script create the folder and then the file. THE PROBLEM is that this script create the folder, but note the file in it. The error is "The file $filename is not writable" Somewhere is a bug, and i don`t know where. For few times it worked, but now appears that error. I hope for some help on that $date = date("d.m.Y"); $titlu = $_POST['titlu_introdus']; $text = $_POST['text_introdus']; $semnatura = $_POST['redactor_introdus']; $nr = $_POST['numar_introdus']; $create = touch ("Server/$nr" . "/" . "$semnatura" . " ". "$date" . " ". "$titlu" . "." . "doc", "rw"); $filename ="Server/$nr" . "/" . "$semnatura" . " ". "$date" . " ". "$titlu" . "." . "doc"; $continut = "$titlu" . " " . "$text"; if(!is_dir("Server/$nr/")) { mkdir ("Server/$nr/"); $create; } else { $create; } if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open $filename"; exit; } // Write $continut to our opened file. if (fwrite($handle, $continut) === FALSE) { echo "Cannot write in $filename"; exit; } echo "Done: " . "<strong>" . "$titlu" . "</strong>" . " Written by" . "<strong>" . "$semnatura" . "</strong>" . " is in directory Server/$nr "; fclose($handle); } else { echo "The file $filename is not writable"; } ?>

« previous php.notes (#91735) next »