I'm currenly running a codeigniter website and i'm trying to read and process a simple .csv file hosted in another URL.
I have the code working good, but I experienced long waiting times no mather the size of the file.
$target_file = "https://website.com/uploads/import_orders.txt";
$extension = pathinfo($target_file,PATHINFO_EXTENSION);
$allowed_ext = array("csv", "txt");
if (in_array($extension, $allowed_ext)) {
$handle = fopen($target_file, "r");
if (empty($handle) === false) {
while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) {
print_r($data);
}
fclose($handle);
}
}
The file is processed and printed correctly. But no mather if there are 2 rows or 500 rows, it always waits at least 5 minutes.
I tested it inserting values in the database and it's curious, all the values are almost inserted in no time except the latest row. When the execution ends it adds the latest row values.
It's like the file is not closed correctly or something and the server keeps waiting.
Any clues about whats happening?
Thanks!