在laravel中使用值作为验证检查

时间:2017-06-22 08:16:16

标签: laravel laravel-5

我创建了一个脚本,它将zip文件分开并计算该zip文件中的文件数量。对于验证检查,我需要使用该函数发出的INT并对其执行if语句,如何才能使其工作?

$zipFile = $request->file('fupload');
    $templatename = $request->input('template_name');
    $file_to_open = $request->file('fupload')->getRealPath();
    $target = storage_path();

    $zip = new \ZipArchive();
    if ($zip->open($file_to_open) == TRUE) {

        for ($i = 0; $i < $zip->numFiles; $i++) {
            $filename = $zip->getNameIndex($i);

            if ( stristr($filename, '__MACOSX') === FALSE )
            {
                $path_parts = pathinfo($filename);

                if ( isset($path_parts['extension']) && !isset( $this->extensions[$path_parts['extension']] ) )
                {
                    $this->extensions[$path_parts['extension']] = 1;
                } else if ( isset($path_parts['extension']) )
                {
                    $this->extensions[$path_parts['extension']] = $this->extensions[$path_parts['extension']] + 1;
                }

                if ( isset($path_parts['extension']) && ($path_parts['extension'] == 'html' || $path_parts['extension'] == 'htm' ) )
                {
                    $this->html = $zip->getFromName($filename);
                    $this->files[] = (object) [ 'filename' => basename($filename), 'contents' => $zip->getFromName($filename)];
                } else if ( isset($path_parts['extension']) ) {
                    $this->files[] = (object) [ 'filename' => basename($filename), 'contents' => $zip->getFromName($filename)];
                }
            }
        }
        echo '<pre>';
        var_dump($templatename, $this->extensions);
        $this->validateZipfiles();

    }
    unlink($file_to_open);
}

0 个答案:

没有答案