我创建了一个脚本,它将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);
}