0

I am using Laravel Excel in my Laravel 4.2 project. I tried to import simple xls file but I am getting error because of slashes. I am using windows development environment currently. I know this error will be gone if I will use linux development environment. Please help me how to get rid of following error. Problem is about slashes.

Error: Could not open C:\xampp\htdocs\campusc/tpstudentupload.xls for reading! File does not exist.

following is my code written in controller.

public function upload(){
    try {
        $result = Excel::selectSheets('Sheet1')->load("tpstudentupload.xls",function($reader){
        })->get();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}

Thanks

lehins
  • 9,642
  • 2
  • 35
  • 49

1 Answers1

0

You can try to use DIRECTORY_SEPARATOR

Or define your own

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')           
    define('DS', '\\');
else 
    define('DS', '/');

And then replace all slashes with DS or DIRECTORY_SEPARATOR

Kiril
  • 331
  • 1
  • 5