Forum Moderators: coopster
I have the following code
$file = "/home/public_html/orders.txt";
if (file_exists($file)) {
if (filesize($file) > 5242880) {
rename($file, "/home/public_html/orders_".date(Ymd).".txt");
if ($ifarray == 1) {
$string = join('', $data);
$fr = fopen($file,'a');
fputs($fr, $string);
} else {
$fr = fopen($file,'a');
$data = $data."\n";
fputs($fr, $data);
}
fclose($fr);
} else {
if ($ifarray == 1) {
$string = join('', $data);
$fr = fopen($file,'a');
fputs($fr, $string);
} else {
$fr = fopen($file,'a');
$data = $data."\n";
fputs($fr, $data);
}
fclose($fr);
}
} else {
$fr = fopen($file,'a');
$data = $data."\n";
fputs($fr, $data);
fclose($fr);
}
}
The filesize
echo filesize($file);
is currently 6187229
For some reason I am not able to change the file name once it exceeds the target filesize.
Any ideas?
Thanks.