Error with file script
Posted: Sun May 18, 2003 10:24 pm
I have a list of files that need to be edited. The list is inside the file called "filelist.txt". I am trying to make a program that opens "filelist.txt" and then opens up every filename inside "filelist.txt" and creates a copy of the file after a certain string has been changed.
Here is my php code:
and this is the error I get:
Warning: fopen(apply.html ) [function.fopen]: failed to create stream: Invalid argument in C:\Program Files\Apache Group\Apache2\mc0\fileedit.php on line 8
Cannot open for reading and editing.
Now this code works but only if there is one filename inside "filelist.txt".
Here is my php code:
Code: Select all
<?php
$filename = "filelist.txt";
$filelist = fopen( $filename, "r") or die("Cannot open $filename for reading.");
while (!feof($filelist))
{
$fte = fgets($filelist, 1024);
$file = fopen($fte, "r") or die("Cannot open $file for reading and editing.");
while(!feof($file))
{
$lte = fgets($file, 1024);
$newFile = fopen("newFiles/$fte", "a");
fwrite($newFile, ereg_replace("layout.css","style.css",$lte));
}
print "File $fte has been created and edited!";
}
print "<h1>Done!</h1>";
?>Warning: fopen(apply.html ) [function.fopen]: failed to create stream: Invalid argument in C:\Program Files\Apache Group\Apache2\mc0\fileedit.php on line 8
Cannot open for reading and editing.
Now this code works but only if there is one filename inside "filelist.txt".