I'm trying to import from xlsx file into mysql using php . On a home computer running OpenServer, everything works like a clock, on the hosting issues:

Warning: include_once (/var/www/scs/data/www/domain.ru/engine/classes/phpexel.php): failed to open stream: There is no such file or directory in / var / www / scs / data / www / domain.ru/engine/inc/import.php on line 39 Warning: include_once (): Failed opening '/var/www/scs/data/www/domain.ru/engine/classes/phpexel.php' for inclusion (include_path = '.: / usr / share / php: / usr / share / pear') in /var/www/scs/data/www/domain.ru/engine/inc/import.php on line 39 Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open 1.xlsx for reading! File does not exist. ' in /var/www/scs/data/www/domain.ru/engine/classes/PHPExcel/Reader/Excel2007.php:82 Stack trace: # 0 /var/www/scs/data/www/domain.ru/engine /classes/PHPExcel/IOFactory.php(268): PHPExcel_Reader_Excel2007-> canRead ('1.xlsx') # 1 /var/www/scx/data/www/domain.ru/engine/classes/PHPExcel/IOFactory.php ( 191): PHPExcel_IOFactory :: createReaderForFile ('1.xlsx') # 2 /var/www/scs/data/www/domain.ru/engine/inc/import.php(41): PHPExcel_IOFactory :: load ('1. xlsx ') # 3 /var/www/scs/data/www/domain.ru/engine/inc/import.php(64): getXLS (' 1.xlsx ') # 4 / var / www / scs / data / www / domain.ru / cpanel.php (100): include_once ('/ var / www / scs / da ...') # 5 {main} thrown in /var/www/scs/data/www/domain.ru /engine/classes/PHPExcel/Reader/Excel2007.php on line 82

code itself:

function getXLS($xls) { include_once ENGINE_DIR . '/classes/phpexel.php'; include_once ENGINE_DIR . '/classes/PHPExcel/IOFactory.php'; $objPHPExcel = PHPExcel_IOFactory::load($xls); $objPHPExcel->setActiveSheetIndex(0); $aSheet = $objPHPExcel->getActiveSheet(); //этот массив Π±ΡƒΠ΄Π΅Ρ‚ ΡΠΎΠ΄Π΅Ρ€ΠΆΠ°Ρ‚ΡŒ массивы содСрТащиС Π² сСбС значСния ячССк ΠΊΠ°ΠΆΠ΄ΠΎΠΉ строки $array = array(); //ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠΌ ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€ строки ΠΈ пройдСмся ΠΏΠΎ Π½Π΅ΠΌΡƒ Ρ†ΠΈΠΊΠ»ΠΎΠΌ foreach ($aSheet->getRowIterator() as $row) { //ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠΌ ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€ ячССк Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ строки $cellIterator = $row->getCellIterator(); //пройдСмся Ρ†ΠΈΠΊΠ»ΠΎΠΌ ΠΏΠΎ ячСйкам строки //этот массив Π±ΡƒΠ΄Π΅Ρ‚ ΡΠΎΠ΄Π΅Ρ€ΠΆΠ°Ρ‚ΡŒ значСния ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½ΠΎΠΉ строки $item = array(); foreach ($cellIterator as $cell) { //заносим значСния ячССк ΠΎΠ΄Π½ΠΎΠΉ строки Π² ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½Ρ‹ΠΉ массив array_push($item, iconv('utf-8', 'cp1251', $cell->getCalculatedValue())); } //заносим массив со значСниями ячССк ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½ΠΎΠΉ строки Π² "ΠΎΠ±Ρ‰ΠΈΠΉ массв строк" array_push($array, $item); } return $array; } $xlsData = getXLS($_FILES['file']['tmp_name']); //ΠΈΠ·Π²Π»Π΅Π°Π΅ΠΌ Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· XLS 

I don’t know exactly what the PHP version is about on both the computer and server: 5.4.44-0

Closed due to the fact that off-topic participants BogolyubskiyAlexey , LEQADA , zRrr , korytoff , torokhkun 3 Dec '15 at 14:38 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - BogolyubskiyAlexey, LEQADA, zRrr, korytoff, torokhkun
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    He clearly says that /var/www/scs/data/www/domain.ru/engine/classes/phpexel.php is not found. Look where you actually have this file and correct the paths, your ENGINE_DIR may be wrong - Mike
  • in the same file connects parse.class.php include_once ENGINE_DIR. '/classes/parse.class.php'; And it works fine. - gor.nizon
  • Well, you obviously look at the disk. If he says that there is no file, then it is not there. Well, or some kind of exotic with the rights to it - Mike
  • he has the disc, and he has the same rights as parse.class.php - gor.nizon
  • In the corrected question, it became easier to read the error. php hike in place, but they can not find: Could not open 1.xlsx for reading! File does not exist. Check where you have this 1.xlsx, if the current directory during the execution of the script is the same as this file and if it has rights - Mike

1 answer 1

An error occurred while installing php on the server. Helped reinstall. Thanks to all.