Initial commit: Backup der Webseiten
- zoesch.de - blitzkiste.net - gruene-hassberge (norbert.zoesch.de) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
25
zoesch.de/ImageUpload/views/gallery.php
Normal file
25
zoesch.de/ImageUpload/views/gallery.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
//function call
|
||||
return showImages();
|
||||
//function defintion
|
||||
function showImages()
|
||||
{
|
||||
$out = '<h1>Image Gallery</h1>';
|
||||
$out .= "<ul id='images'>";
|
||||
$folder = 'img';
|
||||
$filesInFolder = new DirectoryIterator($folder);
|
||||
while ($filesInFolder->valid()) {
|
||||
$file = $filesInFolder->current();
|
||||
$filename = $file->getFilename();
|
||||
$src = "$folder/$filename";
|
||||
$fileInfo = new Finfo(FILEINFO_MIME_TYPE);
|
||||
$mimeType = $fileInfo->file($src);
|
||||
if ($mimeType === 'image/jpeg') {
|
||||
$out .= "<li><img src='$src' /></li>";
|
||||
}
|
||||
$filesInFolder->next();
|
||||
}
|
||||
$out .= '</ul>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
7
zoesch.de/ImageUpload/views/navigation.php
Normal file
7
zoesch.de/ImageUpload/views/navigation.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
return "
|
||||
<nav>
|
||||
<a href='index.php?page=gallery'>Gallery</a>
|
||||
<a href='index.php?page=upload'>Upload new image</a>
|
||||
</nav>
|
||||
";
|
||||
8
zoesch.de/ImageUpload/views/upload-form.php
Normal file
8
zoesch.de/ImageUpload/views/upload-form.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return "
|
||||
Upload new jpg images</h1>
|
||||
<form method='post' action='index.php?page=upload' enctype='multipart/form-data' >
|
||||
<label>Find a jpg image to upload</label>
|
||||
<input type='file' name='image-data' accept='image/jpeg'/>
|
||||
<input type='submit' value='upload' name='new-image' />
|
||||
</form>";
|
||||
29
zoesch.de/ImageUpload/views/upload.php
Normal file
29
zoesch.de/ImageUpload/views/upload.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
//complete source code for views/upload.php
|
||||
//$newImageSubmitted is TRUE if form was submitted, otherwise FALSE
|
||||
$newImageSubmitted = isset($_POST['new-image']);
|
||||
if ($newImageSubmitted) {
|
||||
//this code runs if form was submitted
|
||||
$output = upload();
|
||||
} else {
|
||||
//this runs if form was NOT submitted
|
||||
$output = include_once 'views/upload-form.php';
|
||||
}
|
||||
|
||||
return $output;
|
||||
//declare new function
|
||||
function upload()
|
||||
{
|
||||
include_once 'classes/Uploader.class.php';
|
||||
//image-data is the name attribute used in <input type='file' />
|
||||
$uploader = new Uploader('image-data');
|
||||
$uploader->saveIn('img');
|
||||
$fileUploaded = $uploader->save();
|
||||
if ($fileUploaded) {
|
||||
$out = 'new file uploaded';
|
||||
} else {
|
||||
$out = 'something went wrong';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
Reference in New Issue
Block a user