dave mccourt
09-18-2002, 12:08 PM
hi
i've set up a simple content management system using php. the cms flash movie reads and can write to a txt file using php. the problem is when the file is read (back into flash) and written a few times, extra empty or invisible characters apeear at the end of the txt file.
i have 2 php scripts that are used by the flash cms movie.
getfile.php reads the txt file into flash for editing:
<?
// Attempt to open file for reading
$file = @fopen($filename, "r");
// If the file was opened successfully...
if ($file) {
print "&status=$filename opened successfully!\n";
$output = fread($file, 11000);
print "&output=" . urlencode($output);
} else {
// Otherwise output failure message
print "&status=File not opened!\n";
}
?>
writefile.php writes the amended text to the txt file:
<?
urlencode($output);
$new = stripslashes($output);
// Attempt to open file for writing
$writable = @fopen($filename, "w+");
// If the file was opened successfully...
if ($writable) {
//write to file
fwrite($writable, $new);
fclose($writable);
print "&status=The file, $filename was updated successfully.";
} else {
// Otherwise output failure message
print "&status=File not updated to. Please click the back button to try again.\n";
}
?>
anyone know why this is?
many thanks
dave
i've set up a simple content management system using php. the cms flash movie reads and can write to a txt file using php. the problem is when the file is read (back into flash) and written a few times, extra empty or invisible characters apeear at the end of the txt file.
i have 2 php scripts that are used by the flash cms movie.
getfile.php reads the txt file into flash for editing:
<?
// Attempt to open file for reading
$file = @fopen($filename, "r");
// If the file was opened successfully...
if ($file) {
print "&status=$filename opened successfully!\n";
$output = fread($file, 11000);
print "&output=" . urlencode($output);
} else {
// Otherwise output failure message
print "&status=File not opened!\n";
}
?>
writefile.php writes the amended text to the txt file:
<?
urlencode($output);
$new = stripslashes($output);
// Attempt to open file for writing
$writable = @fopen($filename, "w+");
// If the file was opened successfully...
if ($writable) {
//write to file
fwrite($writable, $new);
fclose($writable);
print "&status=The file, $filename was updated successfully.";
} else {
// Otherwise output failure message
print "&status=File not updated to. Please click the back button to try again.\n";
}
?>
anyone know why this is?
many thanks
dave