You are here

public static function PHPExcel_Shared_File::file_exists in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/File.php \PHPExcel_Shared_File::file_exists()

* Verify if a file exists * *

Parameters

string $pFilename Filename: * @return bool

1 call to PHPExcel_Shared_File::file_exists()
PHPExcel_Writer_Excel2007_ContentTypes::_getImageMimeType in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php
* Get image mime type * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/File.php, line 73

Class

PHPExcel_Shared_File
PHPExcel_Shared_File

Code

public static function file_exists($pFilename) {

  // Sick construction, but it seems that
  // file_exists returns strange values when
  // doing the original file_exists on ZIP archives...
  if (strtolower(substr($pFilename, 0, 3)) == 'zip') {

    // Open ZIP file and verify if the file exists
    $zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
    $archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
    $zip = new ZipArchive();
    if ($zip
      ->open($zipFile) === true) {
      $returnValue = $zip
        ->getFromName($archiveFile) !== false;
      $zip
        ->close();
      return $returnValue;
    }
    else {
      return false;
    }
  }
  else {

    // Regular file_exists
    return file_exists($pFilename);
  }
}