protected function validateFile($path)
    {
        if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) {
            throw new NotFoundException(__d('cake', 'The requested file contains `..` and will not be read.'));
        }
        if (!is_file($path)) {
            deprecationWarning(
                'Automatic prefixing of paths with `APP` by `Response::file()` and `withFile()` is deprecated. ' .
                'Use absolute paths instead.'
            );
            $path = APP . $path;
        }
        if (!Folder::isAbsolute($path)) {
            deprecationWarning(
                'Serving files via `file()` or `withFile()` using relative paths is deprecated.' .
                'Use an absolute path instead.'
            );
        }

        $file = new File($path);
        if (!$file->exists() || !$file->readable()) {
            if (Configure::read('debug')) {
                throw new NotFoundException(sprintf('The requested file %s was not found or not readable', $path));
            }
            throw new NotFoundException(__d('cake', 'The requested file was not found'));
        }

        return $file;
    }
protected function validateFile($path)
    {
        if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) {
            throw new NotFoundException(__d('cake', 'The requested file contains `..` and will not be read.'));
        }
        if (!is_file($path)) {
            deprecationWarning(
                'Automatic prefixing of paths with `APP` by `Response::file()` and `withFile()` is deprecated. ' .
                'Use absolute paths instead.'
            );
            $path = APP . $path;
        }
        if (!Folder::isAbsolute($path)) {
            deprecationWarning(
                'Serving files via `file()` or `withFile()` using relative paths is deprecated.' .
                'Use an absolute path instead.'
            );
        }

        $file = new File($path);
        if (!$file->exists() || !$file->readable()) {
            if (Configure::read('debug')) {
                throw new NotFoundException(sprintf('The requested file %s was not found or not readable', $path));
            }
            throw new NotFoundException(__d('cake', 'The requested file was not found'));
        }

        return $file;
    }
protected function validateFile ( $ path ) { if ( strpos ( $ path , '../' ) !== false || strpos ( $ path , '..\\' ) !== false ) { throw new NotFoundException ( __d ( 'cake' , 'The requested file contains `..` and will not be read.' ) ) ; } if ( ! is_file ( $ path ) ) { deprecationWarning ( 'Automatic prefixing of paths with `APP` by `Response::file()` and `withFile()` is deprecated. ' . 'Use absolute paths instead.' ) ; $ path = APP . $ path ; } if ( ! Folder :: isAbsolute ( $ path ) ) { deprecationWarning ( 'Serving files via `file()` or `withFile()` using relative paths is deprecated.' . 'Use an absolute path instead.' ) ; } $ file = new File ( $ path ) ; if ( ! $ file -> exists ( ) || ! $ file -> readable ( ) ) { if ( Configure :: read ( 'debug' ) ) { throw new NotFoundException ( sprintf ( 'The requested file %s was not found or not readable' , $ path ) ) ; } throw new NotFoundException ( __d ( 'cake' , 'The requested file was not found' ) ) ; } return $ file ; }
Validate a file path is a valid response body.

@param string $path The path to the file.
@throws \Cake\Http\Exception\NotFoundException
@return \Cake\Filesystem\File
Validate a file path is a valid response body .