added orai

This commit is contained in:
szabomarton 2024-11-14 12:01:45 +01:00
parent 0334df1ea4
commit 6146ada108
4 changed files with 93 additions and 0 deletions

69
20241114/241104/head.php Normal file
View File

@ -0,0 +1,69 @@
<?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;">';
}
}
*/
?>

24
20241114/241104/html.php Normal file
View File

@ -0,0 +1,24 @@
<?php
include("head.php");
?>
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Képek kezelése</title>
</head>
<body>
<h1>Képek feltöltése PHP-val</h1>
<form action="#" method="POST" enctype="multipart/form-data">
Név: <input type="text" name="kepnev"><br>
<input type="file" name="kepfajl"><br>
<button type="submit">Feltölt</button>
</form>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB