getExt() 개인적인 메소드

+---------------------------------------------------------- 取得上传文件的后缀 +---------------------------------------------------------- +----------------------------------------------------------
private getExt ( string $filename ) : boolean
$filename string 文件名 +----------------------------------------------------------
리턴 boolean +----------------------------------------------------------
예제 #1
0
 static function multiUpload($files, $destination = null, $name = null)
 {
     $result = array();
     if (self::isMultiFile($files)) {
         $arrayFiles = self::normalizeArray($files);
         $i = 0;
         foreach ($arrayFiles as $value) {
             $tmp = new UploadFile($value);
             if ($destination !== null) {
                 $tmp->setDestination($destination);
             }
             if ($name !== null) {
                 $tmp->setName($name);
             }
             $tmp->upload();
             $cod = $tmp->getError();
             $errMsg = $tmp->getError_message();
             $arrayRes = array($cod, $errMsg, $tmp->getDestination(), $tmp->getName() . '.' . $tmp->getExt(), $value['name']);
             array_push($result, $arrayRes);
         }
     } else {
         $tmp = new UploadFile($files);
         if ($destination !== null) {
             $tmp->setDestination($destination);
         }
         if ($name !== null) {
             $tmp->setName($name);
         }
         $tmp->upload();
         $cod = $tmp->getError();
         $errMsg = $tmp->getError_message();
         $arrayRes = array($cod, $errMsg, $tmp->getDestination(), $tmp->getName() . '.' . $tmp->getExt(), $value['name']);
         array_push($result, $arrayRes);
     }
     return $result;
 }
예제 #2
0
        $cancion = new uploadFile($_FILES['cancion']);
        $nombre_tipado = $privado . '_' . $usuario . '_' . $categoria . '_' . $cancion->getName();
        if ($cancion->getError() === UPLOAD_ERR_OK && $cancion->getExt() === "mp3") {
            $cancion->setName($nombre_tipado);
            if (!$cancion->upload()) {
                echo "<h2>Error: " . $cancion->getError_message() . "</h2>";
                echo $cancion;
            } else {
                echo "<h2>Error: " . $cancion->getError_message() . "</h2>";
            }
        } else {
            echo "<h2>No ha llegado ninguna cancion: " . $cancion->getError_message() . "</h2>";
        }
        if (isset($_FILES['img'])) {
            $imagen = new UploadFile($_FILES['img']);
            if ($imagen->getError() === UPLOAD_ERR_OK && $imagen->getExt() === "jpg") {
                $imagen->setName($nombre_tipado);
                if (!$imagen->upload()) {
                    echo "<h2>Error: " . $imagen->getError_message() . "</h2>";
                }
            } else {
                echo "<h2>Error: " . $imagen->getError_message() . "</h2>";
            }
        } else {
            echo "<h2>No ha subido ninguna imagen</h2>";
        }
    } else {
        echo "<h2>No ha subido ninguna canción</h2>";
    }
} else {
    echo "EEEEEEEEEEEEEEEEEEEE";