0

I have written a piece of code that turns into array an excel that a user uploads. on 5/10 rows works totally fine but if i try to upload a bigger file ( not that big, something like 150 rows X 8 columns) i get a timeout error.
    $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
    $reader->setReadDataOnly(true);

    $spreadsheet = $reader->load($_FILES["file"]["tmp_name"]);

    $sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
    $data = $sheet->toArray();

what am i doing wrong?

The error message

Fatal error: Maximum execution time of 120 seconds exceeded in C:\xampp\htdocs\testversion\vendor\kint-php\kint\src\Object\Blob.php on line 72

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
gurgu
  • 11
  • ___get a timeout error.___ Can we see the error please. Always show any error message, in their entirety, no summarisation please – RiggsFolly Mar 14 '22 at 11:09
  • sure, here it is: Fatal error: Maximum execution time of 120 seconds exceeded in C:\xampp\htdocs\testversion\vendor\kint-php\kint\src\Object\Blob.php on line 72 – gurgu Mar 14 '22 at 12:59
  • And which of the 5 lines of code you show is line 72 and is this the code in `Blob.php` – RiggsFolly Mar 14 '22 at 13:01
  • public static function detectEncoding($string){ if (function_exists('mb_detect_encoding')){ return mb_detect_encoding($string, self::$char_encodings, true); } if (!function_exists('iconv')){ return 'UTF-8'; } $md5 = md5($string); foreach (self::$char_encodings as $encoding){ // fuck knows why, //IGNORE and //TRANSLIT still throw notice if (md5(@iconv($encoding, $encoding, $string)) === $md5) { return $encoding; } } return false; } – gurgu Mar 14 '22 at 13:14
  • no. blob.php is a file containing some of the function being called. the error is at the first return – gurgu Mar 14 '22 at 13:14
  • Do you see the [Edit](https://stackoverflow.com/posts/71464885/edit) link under the Question box. You should use that to add to or amend your question as you service our requests for more information! Because nobody can read code in a comment – RiggsFolly Mar 14 '22 at 13:16
  • my bad, still new to stackoverflow. Anyway i managed to resolve the problem, it was the excel file itself, i casually copy-pasted everything on a brand new file and every thing worked out fine. ty for your assistance anyway! – gurgu Mar 14 '22 at 13:31

0 Answers0