相关疑难解决方法(0)

上传表单中的php检查文件扩展名

我检查文件扩展名是否上传或未上传.我的方法工作但现在我需要了解,我的方法(pathinfo)是真的吗?另一种更好更快的方式?!谢谢

$filename = $_FILES['video_file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext !== 'gif' || $ext !== 'png' || $ext !== 'jpg') {
    echo 'error';
}
Run Code Online (Sandbox Code Playgroud)

php file-upload

48
推荐指数
4
解决办法
20万
查看次数

使用PHP列出.7z,.rar和.tar存档中的文件

我想列出存档中的文件,而不是它们的提取.

我感兴趣的档案类型:

  • .7z(7-Zip)
  • .rar(WinRAR)
  • .tar(POSIX,例如GNU tar).
  • .zip(ISO标准,例如WinZip)

对于.zip文件,我已经能够实现这个目的:

<?php
    $za = new ZipArchive();
    $za->open('theZip.zip');
    for ($i = 0; $i < $za->numFiles; $i++) {
        $stat = $za->statIndex($i);
        print_r(basename($stat['name']) . PHP_EOL);
    }
?>
Run Code Online (Sandbox Code Playgroud)

但是,我没有设法为.7z文件做同样的事情.没有测试.rar和.tar,但也需要它们.

php compression file archive ziparchive

10
推荐指数
1
解决办法
3674
查看次数

标签 统计

php ×2

archive ×1

compression ×1

file ×1

file-upload ×1

ziparchive ×1