This commit is contained in:
Dávid Jančár 2024-05-22 21:40:17 +02:00
parent e6fc5c4161
commit d4b1ee3395
2 changed files with 57 additions and 0 deletions

57
stranky/upload.php Normal file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>upload</title>
</head>
<body>
<?php
$conn = mysqli_connect('localhost','root','','example');
if(isset($_POST['submit'])){
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$path = "files/".$fileName;
$query = "INSERT INTO filedownload(filename) VALUES ('$fileName')";
$run = mysqli_query($conn,$query);
if($run){
move_uploaded_file($fileTmpName,$path);
echo "success";
}
else{
echo "error".mysqli_error($conn);
}
}
?>
<table border="1px" align="center">
<tr>
<td>
<form action="Upload.html" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit" name="submit"> Upload</button>
</form>
</td>
</tr>
<tr>
<td>
<?php
$query2 = "SELECT * FROM filedownload ";
$run2 = mysqli_query($conn,$query2);
while($rows = mysqli_fetch_assoc($run2)){
?>
<a href="download.php?file=<?php echo $rows['filename'] ?>">Download</a><br>
<?php
}
?>
</td>
</tr>
</table>
</body>
</html>