Current Path : /data/web/virtuals/51568/virtual/www/www/editor/ |
Current File : /data/web/virtuals/51568/virtual/www/www/editor/clanek-fotka-uloz.php |
<?php require "../../class/pdoDB.class.php"; $pdo = new pdoDB(); require "../../class/obrazek.class.php"; $id = (isset($_POST["id"])) ? $_POST["id"] : 0; $cesta = (isset($_POST["cesta"])) ? $_POST["cesta"] : ''; $targetDir = "../../ftp/articles/"; if(!is_dir($targetDir)){ mkdir($targetDir); } /* if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {$url = 'https://'; } else {$url = 'http://';} $url.= $_SERVER['HTTP_HOST']; $fileName = $url.'/ftp/soubory/'.$cesta; */ $fileName = '../../ftp/soubory/'.$cesta; try { $ext = strtolower(pathinfo($fileName)['extension']); if ($ext == 'jpeg') {$ext = 'jpg';} $targetFilePathTmp = $targetDir.$id.'tmp.'.$ext; $targetFilePath = $targetDir.$id.'.'.$ext; copy($fileName, $targetFilePathTmp); $obrazek=new Obrazek(); $obrazek->nastav($targetFilePathTmp,$targetFilePathTmp); $obrazek->zmensi(200, 100, 85, $targetFilePath); unlink ($targetFilePathTmp); $update = "update `clanky` set `fotka` = :fotka where `id` = :id"; $pdo->execute($update, Array(':fotka' => $id.'.'.$ext, ':id' => $id)); } catch (Exception $e) { $result = $e->getMessage(); } echo $id.'.'.$ext; ?>