added doga
This commit is contained in:
parent
52e5ec300e
commit
484964820c
0
20241024/kepek/asd.txt
Normal file
0
20241024/kepek/asd.txt
Normal file
BIN
20241121/directory/SA.jpg
Normal file
BIN
20241121/directory/SA.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
106
20241121/feltolt.php
Normal file
106
20241121/feltolt.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"]=="POST")
|
||||
{
|
||||
if (!isset($_SESSION["dirname"]) && !isset($_POST["dirname"])){
|
||||
$celkonyvtar = "directory/";
|
||||
} else{
|
||||
if (isset($_POST["dirname"]) || isset($_SESSION["dirname"])){
|
||||
$_SESSION["dirname"] = $_POST["dirname"];
|
||||
$celkonyvtar = $_SESSION["dirname"]."/";
|
||||
mkdir($celkonyvtar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!is_dir($celkonyvtar))
|
||||
{
|
||||
mkdir($celkonyvtar);
|
||||
}
|
||||
|
||||
$uname = uniqid();
|
||||
|
||||
|
||||
$celfajl = $celkonyvtar.$_FILES["kepfajl"]["name"];
|
||||
|
||||
|
||||
$fajlkiterjesztes = strtolower(pathinfo($celfajl,PATHINFO_EXTENSION));
|
||||
$uploadOK = 1;
|
||||
|
||||
$maxmeret = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (isset($_FILES["kepfajl"])){
|
||||
|
||||
if ($fajlkiterjesztes =="jpg" || $fajlkiterjesztes=="txt")
|
||||
{
|
||||
if ($fajlkiterjesztes == "jpg"){
|
||||
$maxmeret = 5*1024*1024;
|
||||
if (getimagesize($_FILES["kepfajl"]["tmp_name"])===false)
|
||||
{
|
||||
$uploadOK = 0;
|
||||
echo "Nem kép lett megadva.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($fajlkiterjesztes == "txt"){
|
||||
$maxmeret = 1*1024*1024;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$uploadOK = 0;
|
||||
echo "Nem megengedett képformátum";
|
||||
}
|
||||
|
||||
if ($_FILES["kepfajl"]["size"]>$maxmeret)
|
||||
{
|
||||
$uploadOK = 0;
|
||||
echo "Túl nagy állomány";
|
||||
}
|
||||
|
||||
if ($uploadOK==1)
|
||||
{
|
||||
|
||||
$vanmar = 0;
|
||||
if (file_exists($celfajl))
|
||||
{
|
||||
$vanmar = 1;
|
||||
}
|
||||
|
||||
if (move_uploaded_file($_FILES["kepfajl"]["tmp_name"],$celkonyvtar.$_POST["kepnev"].".".$fajlkiterjesztes)==true)
|
||||
{
|
||||
if ($vanmar==0){
|
||||
$_SESSION["kepek"][] = $celfajl;
|
||||
|
||||
//vizjel($celkonyvtar, $celfajl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Képek listázása tényleges állományok alapján
|
||||
//$kepek = glob($celkonyvtar."*");
|
||||
|
||||
/*
|
||||
foreach ($kepek as $img)
|
||||
{
|
||||
echo '<img src="'.$img.'" style="width: 200px; height: auto;">';
|
||||
}
|
||||
*/
|
||||
//Képek listázása feltöltés után SESSION-ből
|
||||
/*
|
||||
if (isset($_SESSION["kepek"]))
|
||||
{
|
||||
foreach ($_SESSION["kepek"] as $value)
|
||||
{
|
||||
echo '<img src="'.$value.'" style="width: 200px; height: auto;">';
|
||||
}
|
||||
}
|
||||
*/
|
||||
?>
|
28
20241121/index.php
Normal file
28
20241121/index.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
include("feltolt.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>Fájlok feltöltése PHP-val</h1>
|
||||
<form action="#" method="POST" enctype="multipart/form-data">
|
||||
Név: <input type="text" name="kepnev" required><br>
|
||||
<input type="file" name="kepfajl" required><br>
|
||||
<button type="submit">Feltölt</button>
|
||||
</form>
|
||||
<br>
|
||||
<form method="POST">
|
||||
Létrehozandó könyvtár neve: <input type="text" name="dirname" required><br>
|
||||
<button type="submit">Feltölt</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user