there is such code here:

$file_path_excel = "http://site.ua/system/PHPExcel/my.xls"; function readExelFile($filepath){ require_once "Classes/PHPExcel.php"; //подключаем наш фреймворк $ar=array(); // инициализируем массив $inputFileType = PHPExcel_IOFactory::identify($filepath); // узнаем тип файла, excel может хранить файлы в разных форматах, xls, xlsx и другие $objReader = PHPExcel_IOFactory::createReader($inputFileType); // создаем объект для чтения файла $objPHPExcel = $objReader->load($filepath); // загружаем данные файла в объект $ar = $objPHPExcel->getActiveSheet()->toArray(); // выгружаем данные из объекта в массив return $ar; //возвращаем массив } $ar=readExelFile($file_path_excel); foreach($ar as $ar_colls){ делаем что то.... 

On the way that I insert the file is downloaded, if you go through the browser. and phpexel cannot open it.

error code

 <b>Fatal error</b>: Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open http://.....ua/system/PHPExcel/my.xls for reading! File does not exist.' in ....www/system/PHPExcel/Classes/PHPExcel/Reader/Excel5.php:433 

Tell me how to get a file from a remote server?

thank

    2 answers 2

    Tell me how to get a file from a remote server?

    Try this

     $filecontent = file_get_contents("http://site.ua/system/PHPExcel/my.xls"); if (!$filecontent){ throw new Exception("Can't read remote file"); } file_put_contents(PATH_TMP."/my.xls", $filecontent); $ar=readExelFile(PATH_TMP."/my.xls"); ... 
    • Just now I read the documentation on these functions. thank. I'll try now - mydls1
    • Well, so for a change if(copy("http://site.ua/system/PHPExcel/my.xls",PATH_TMP."/my.xls")) { readExcelFile()} and you have an error for even if The file readExcelFile still read it. - Naumov
    • @Naumov, not in error handling was the meaning of the post. Edited - Goncharov Alexander
    • @GoncharovAleksandr I didn’t comment about error handling but about the fact that you had an error in the algorithm. Well, the file_get_contents and file_put_contents . the same actions are performed by one copy command. Plus, if file_get_contents requests an inaccessible file or server, you will get a bad getway error. Therefore, it is better to add certain timeout requests in the context. - Naumov
     $filename = basename($file_path_excel); $content = file_get_contents($file_path_excel); if (file_put_contents($filename, $content)) { readExelFile($filename); unlink($filename); } else die("Something went wrong"); 

    You must first save the file locally to your system, then open it.