69 lines
1.3 KiB
PHP
69 lines
1.3 KiB
PHP
|
<?php
|
||
|
session_start();
|
||
|
$celkonyvtar = "kepek/";
|
||
|
|
||
|
if ($_SERVER["REQUEST_METHOD"]=="POST")
|
||
|
{
|
||
|
if(!is_dir($celkonyvtar)){
|
||
|
mkdir($celkonyvtar);
|
||
|
}
|
||
|
$celfajl = $celkonyvtar.$_FILES["kepfajl"]["name"];
|
||
|
|
||
|
// $kiterjesztes = Itt hagytuk abba :)
|
||
|
$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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$kepek = glob($celkonyvtar.'*');
|
||
|
|
||
|
foreach ($kepek as $value)
|
||
|
{
|
||
|
echo '<img src="'.$value.'" style="width: 200px; height: auto;">';
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
if (isset($_SESSION["kepek"]))
|
||
|
{
|
||
|
foreach ($_SESSION["kepek"] as $value)
|
||
|
{
|
||
|
echo '<img src="'.$value.'" style="width: 200px; height: auto;">';
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
?>
|