I am making a console viewer for a Minecraft server, but when I get to the stage where I only need to display the text in a browser, It wont let me with this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes) in C:\xampp\htdocs\testingfile.php on line 17
I'm Guessing that it wont display because the file is too big? The file is about 4.5MB. I want to display the 10 most recent lines from the file.
Here is my code:
<?php
// define some variables
$local_file = 'C:\Users\Oscar\Desktop\worked.txt';
$server_file = 'NN7776801/server.log';
$ftp_server="Lol.Im.Not.Thick";
$ftp_user_name="Jesus";
$ftp_user_pass="ReallyLongPassWordThatYouWontGuessLolGoodLuckMateGuessingThisPass";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
$contents = file($local_file);
$string = implode($contents);
echo $string;
for ($i = 0; $i < 6; $i++) {
echo $local_file[$i] . "\n";
}
}
else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>