mercredi 25 mai 2016

Stop php fwrite if reach 1.5 mb then continue writing to another file

Please help me. I am developing now a text collector. I used only php fwrite to write the text but I want to maximize only the file in 1.5 mb then stop writing on that .txt file then create another .txt file where the fwrite continue its writing. I search also from different sites but many of them I can't understand because I a novice programmer. My code is at bottom and it is wrong. Thank you in advance. Help me:-)

        switch ($FileSizeCounter) {
            case ($FileSizeCounter> 1500000):
                 $myFile2 = 'C:\TextCollector/'.'FilenameA'.'.txt';
                 $fh2 = fopen($myFile2, 'a') or die("can't open file");
                    fwrite($fh2, $RemoveTwo);
                    fclose($fh2);  
                break;
            case ($FileSizeCounter> 3000000):
                 $myFile3 = 'C:\TextCollector/'.'FilenameB'.'.txt';
                 $fh3 = fopen($myFile3, 'a') or die("can't open file");
                    fwrite($fh3, $RemoveTwo);
                    fclose($fh3);  
                break;
            default:
                echo "continue and continue until it stops by the user";
        }

Aucun commentaire:

Enregistrer un commentaire