Home >Backend Development >PHP Tutorial >PHP checks the audio and video file formats and verifies whether the audio and video are forged

PHP checks the audio and video file formats and verifies whether the audio and video are forged

WBOY
WBOYOriginal
2016-07-06 13:52:351573browse

The method of processing images learned from the Internet, detecting forged images with modified suffix names:

<code>//检测伪造
    public function checkFlag() {
        
        $this->flag=@getimagesize($this->fileInfo['tmp_name']);
        if ($this->flag) {
            return true;
        }else {
            $this->error="请上传合法文件";
            return false;
        }
    }</code>

I would like to ask if there is a method similar to getimagesize to detect audio and video, MP3, MP4.

Reply content:

The method of processing images learned from the Internet, detecting forged images with modified suffix names:

<code>//检测伪造
    public function checkFlag() {
        
        $this->flag=@getimagesize($this->fileInfo['tmp_name']);
        if ($this->flag) {
            return true;
        }else {
            $this->error="请上传合法文件";
            return false;
        }
    }</code>

I would like to ask if there is a method similar to getimagesize to detect audio and video, MP3, MP4.

<code>$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $inputFileName);</code>

You can judge by reading the first 8 bytes.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn