public function isFileReady($file_path)
{
// file exists?
if (!file_exists($file_path)) {
throw new \Exception('File ' . $file_path . ' doesn\'t exist', SimpleExcelException::FILE_NOT_FOUND);
// extension valid?
} else {
if (strtoupper(pathinfo($file_path, PATHINFO_EXTENSION)) != strtoupper($this->file_extension)) {
throw new \Exception('File extension ' . strtoupper(pathinfo($file_path, PATHINFO_EXTENSION)) . ' doesn\'t match with ' . $this->file_extension, SimpleExcelException::FILE_EXTENSION_MISMATCH);
// file readable?
} else {
if (($handle = fopen($file_path, 'r')) === FALSE) {
throw new \Exception('Error reading the file in' . $file_path, SimpleExcelException::ERROR_READING_FILE);
fclose($handle);
// okay then
} else {
return TRUE;
}
}
}
}