MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/sites.artinside.com.br/festival/vendor/coffeecode/uploader/src/Media.php
<?php

namespace CoffeeCode\Uploader;

use Exception;

/**
 * Class CoffeeCode Media
 *
 * @author Robson V. Leite <https://github.com/robsonvleite>
 * @package CoffeeCode\Uploader
 */
class Media extends Uploader
{
    /**
     * Allow mp4 video and mp3 audio
     * @var array allowed media types
     * https://www.freeformatter.com/mime-types-list.html
     */
    protected static array $allowTypes = [
        "audio/mp3",
        "audio/mpeg",
        "video/mp4",
    ];

    /**
     * Allowed extensions to types.
     * @var array
     */
    protected static array $extensions = [
        "mp3",
        "mp4"
    ];

    /**
     * @param array $media
     * @param string $name
     * @return string
     * @throws Exception
     */
    public function upload(array $media, string $name): string
    {
        $this->ext($media);

        if (!in_array($media['type'], static::$allowTypes) || !in_array($this->ext, static::$extensions)) {
            throw new Exception("Not a valid media type or extension");
        }

        $this->name($name);
        move_uploaded_file($media['tmp_name'], "{$this->path}/{$this->name}");
        return "{$this->path}/{$this->name}";
    }
}