JonnyH
October 19th, 2007, 17:05
I've been making a script in the admin panel which lets you edit files in the style, so yeah. I've done it all but when you submit to edit, it doesn't do it and comes up with my error message saying there's been a problem. Heres the code which edits the file:
//Edits a file
function edit_file($link,$value) {
if (file_exists($link)) {
$fh = fopen($link,'w');
if(fwrite($fh,$value)) {
fclose($fh);
return true;
}
}
elseif(!file_exists($link)){
return false;
}
}
The code which calls it:
if($this->edit_file("../style/".$this->style."/$name", $_POST['file'])) {
$this->errors("Your file has been successfully edited");
$this->done();
}
else {
$this->errors("There's been a problem while editing your file");
$this->done();
}
EDIT: I've debugged the script and it's returning false on the fwrite function not if it exists.
//Edits a file
function edit_file($link,$value) {
if (file_exists($link)) {
$fh = fopen($link,'w');
if(fwrite($fh,$value)) {
fclose($fh);
return true;
}
}
elseif(!file_exists($link)){
return false;
}
}
The code which calls it:
if($this->edit_file("../style/".$this->style."/$name", $_POST['file'])) {
$this->errors("Your file has been successfully edited");
$this->done();
}
else {
$this->errors("There's been a problem while editing your file");
$this->done();
}
EDIT: I've debugged the script and it's returning false on the fwrite function not if it exists.