Exemple #1
0
<?php

require_once 'class/SimpleUpload.class.php';
if (isset($_FILES)) {
    $upload = new SimpleUpload($_FILES['plik']);
    // Tworzymy nowy obiekt
    // Katalog
    if ($_POST['dest_dir'] != '') {
        $upload->destDir = $_POST['dest_dir'];
    }
    // Prefix
    if ($_POST['file_prefix'] != '') {
        $upload->filePrefix = $_POST['file_prefix'];
    } else {
        $upload->filePrefix = time();
    }
    // Nazwa pliku
    if ($_POST['file_name'] != '') {
        $upload->fileName = $_POST['file_name'];
    }
    $fileSizeB = $upload->getFileSize();
    // bajt B
    $fileSizeK = $upload->getFileSize('K');
    // kibibajt - KiB
    $fileSizeM = $upload->getFileSize('M');
    // mebibajt - MiB
    $fileType = $upload->getFileType();
    $stat = $upload->save();
    if ($stat === false) {
        echo "Błąd: " . $upload->error();
    } else {
 private static function editAvataradmin()
 {
     $sesion = new Session();
     $sesion->administrador();
     $bd = new DataBase();
     $gestor = new ManageUser($bd);
     $user = $gestor->get(Request::get("user"));
     $subir = new SimpleUpload("avatar", $user->getEmail());
     $cambioAvatar = $_FILES["avatar"]['name'];
     if ($cambioAvatar != "" || $cambioAvatar != null) {
         $destino = "plantillas/index/user/avatar/" . $user->getEmail();
         $subir->setDestino($destino);
         $subir->subida();
         $user->setAvatar($user->getEmail() . "." . $subir->getExtension());
         $gestor->setAvatar($user);
         self::viewEditadmin("Avatar cambiado correctamente", "success", $user->getEmail());
     } else {
         self::viewEditadmin("Error al cambiar de avatar", "danger", $user->getEmail());
     }
 }