69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
session_start();
|
|
$celkonyvtar = "kepek/";
|
|
|
|
function vizjeljpg($kepfajl, $celkonyvtar) {
|
|
$img = imagecreatefromjpeg($kepfajl);
|
|
|
|
$wmcolor = imagecolorallocatealpha($img, 255, 255, 255, 25);
|
|
|
|
imagefttext($img, 18,0,0,24, $wmcolor, "Vera.ttf", "WATERMARK");
|
|
|
|
imagejpeg($img, $celkonyvtar."vizejeles.jpg", 75);
|
|
}
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
if (!is_dir($celkonyvtar)) {
|
|
mkdir($celkonyvtar);
|
|
}
|
|
|
|
$uname = uniqid();
|
|
$celfajl = $celkonyvtar.$_FILES["kepfajl"]["name"];
|
|
|
|
$maxmeret = 5 * 1024 * 1024;
|
|
$kepkiterjesztes = strtolower(pathinfo($celfajl, PATHINFO_EXTENSION));
|
|
$uploadOK = 1;
|
|
|
|
if (getimagesize($_FILES["kepfajl"]["tmp_name"]) == false) {
|
|
$uploadOK = 0;
|
|
echo "Nem kép lett megadva!";
|
|
}
|
|
|
|
if ($_FILES["kepfajl"]["size"] > $maxmeret) {
|
|
$uploadOK = 0;
|
|
echo "Túl nagy állomány!";
|
|
}
|
|
|
|
if ($kepkiterjesztes != "jpg" && $kepkiterjesztes != "png") {
|
|
$uploadOK = 0;
|
|
echo "Nem megengedett képformátum";
|
|
}
|
|
|
|
if ($uploadOK == 1) {
|
|
$vanmar = 0;
|
|
if (file_exists($celfajl)) {
|
|
$vanmar = 1;
|
|
}
|
|
|
|
if (move_uploaded_file($_FILES["kepfajl"]["tmp_name"], $celfajl) == true) {
|
|
if ($vanmar == 0) {
|
|
$_SESSION["kepek"][] = $celfajl;
|
|
vizjeljpg($celfajl, $celkonyvtar);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
$kepek = glob($celkonyvtar."*");
|
|
|
|
foreach ($kepek as $img) {
|
|
echo '<img src="'.$img.'" style="width: 200px; height: auto">';
|
|
}
|
|
|
|
// if (isset($_SESSION["kepek"])) {
|
|
// foreach ($_SESSION["kepek"] as $value) {
|
|
// echo '<img src="'.$value.'" style="width: 200px; height: auto;">';
|
|
// }
|
|
// }
|
|
?>
|