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
Release: 2016-07-06 13:52:35
Original
1597 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login

You can judge by reading the first 8 bytes.

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template