I am working on a script that does a daily import of several flat text files into a mysql database. Most of the files work fine, however I have one new addition that is a 3gb text file.
This is the actual code:
$filename="/home/something/13058.txt";
$fp = fopen($filename,'r');
if (!$fp) {echo 'ERROR: Unable to open file.';exit;}
while (!feof($fp)) {
$line = fread($fp, 2048); //use 2048 if very long lines
$record=explode("|",$line);
if($record['0']=="HDR") {
$thisline=strtoupper($record['2']);
echo $thisline;
} else {
}
}
}
When the script gets to the 13058 file, it exits. I tried putting in a test to see if the filesize was over a certain amount to get it to skip the mega file so the database will at least be almost complete.
if(filesize($filename)>"2000000000") { echo $filename." - Did not load, too big"; } else {
///Put above code here
}
But then I get the message:
filesize(): stat failed for /home/something/13058.txt
What am I doing wrong to get the original file to load?
TIA,
Phil