From 37e8710f70ec55430f5bc006a70b7bc672692183 Mon Sep 17 00:00:00 2001
From: Peter Hoppe
Date: Thu, 5 Jan 2023 00:14:33 +0100
Subject: [PATCH] seiten aufrufe
---
php/php-dog/upload.php | 32 ++++++++++++++------------------
src/App.tsx | 3 ++-
src/components/FileUpload.tsx | 3 ++-
src/components/Profil.tsx | 5 +++--
src/components/Qr.tsx | 3 +++
5 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/php/php-dog/upload.php b/php/php-dog/upload.php
index 1b22ee7..d09d5a1 100644
--- a/php/php-dog/upload.php
+++ b/php/php-dog/upload.php
@@ -45,13 +45,13 @@ try {
{
mkdir($targetDir, 0755, true);
}
- echo "targetDir ". $targetDir . "\n";
+// echo "targetDir ". $targetDir . "\n";
$fileName = basename($_FILES["file"]["name"]);
$fileType = pathinfo($fileName, PATHINFO_EXTENSION);
- echo "fileName ".$fileName . "\n";
- echo "fileType ".$fileType . "\n";
+ // echo "fileName ".$fileName . "\n";
+ // echo "fileType ".$fileType . "\n";
if (!in_array($fileType, $allowTypes))
{
@@ -66,7 +66,7 @@ try {
$newFilename = getNewFilename($targetDir, $fileType, 20);
- echo "newFilename ".$newFilename . "\n";
+// echo "newFilename ".$newFilename . "\n";
if (strlen($newFilename) == 0)
@@ -82,40 +82,36 @@ try {
}
$targetFilePath = $targetDir . '/' . $newFilename;
- echo "targetFilePath ". $targetFilePath."\n";
+// echo "targetFilePath ". $targetFilePath."\n";
if (isset($_POST["submit"]) && !empty($_FILES["file"]["name"]))
{
- echo "submit file name ". $_FILES["file"]["name"]."\n";
+// echo "submit file name ". $_FILES["file"]["name"]."\n";
// Upload file to server
if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath))
{
- echo "move ok! ". $targetFilePath."\n";
+// echo "move ok! ". $targetFilePath."\n";
$newPathFilename = '/' . $user["qr_id"] . '/' . $newFilename;
- echo "query " . "UPDATE dogs SET picture = '" . $newPathFilename . "' WHERE qr_id = '" . $user["qr_id"]."'\n";
+// echo "query " . "UPDATE dogs SET picture = '" . $newPathFilename . "' WHERE qr_id = '" . $user["qr_id"]."'\n";
$db_connection = new Database();
$conn = $db_connection->dbConnection();
-
-
- echo var_dump($conn);
+// echo var_dump($conn);
// Insert image file name into database
$statement = $conn->prepare("UPDATE dogs SET picture = :filePic WHERE qr_id = :user_qr_id");
$update = $statement->execute(array('filePic' => $newPathFilename, 'user_qr_id' => $user["qr_id"]));
- echo var_dump($update);
+// echo var_dump($update);
$count = $statement->rowCount();
- echo 'rowcount ' . $count . '\n';
-
-
+// echo 'rowcount ' . $count . '\n';
if ($update && $count > 0)
{
- $result = new CMsg(1, 200, "The file " . $newPathFilename . " has been uploaded successfully.");
- echo $result->jsonarray();
+ $result = new CMsg(1, 200, "The file " . $fileName . " has been uploaded successfully.");
+// echo $result->jsonarray();
}
else
{
$result = new CMsg(0, 500, "File upload failed, please try again.");
- echo $result->jsonarray();
+// echo $result->jsonarray();
}
}
else
diff --git a/src/App.tsx b/src/App.tsx
index 27ce1f6..7d08fbf 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -26,7 +26,8 @@ const App: React.FC = () =>
{user && }
- {user && } />}
+ {user && } />}
+ {/* {user && } />} */}
{!user && } />}
{user && } />}
{user && } />}
diff --git a/src/components/FileUpload.tsx b/src/components/FileUpload.tsx
index a250400..789ac89 100644
--- a/src/components/FileUpload.tsx
+++ b/src/components/FileUpload.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { Link } from "react-router-dom";
import UploadService from "../services/FileUploadService";
import IFile from "../types/File";
import PreviewUpload from "./PreviewUpload";
@@ -91,7 +92,7 @@ const FileUpload: React.FC = () =>
{message}
)}
-
+ Zurück zum Profil
);
diff --git a/src/components/Profil.tsx b/src/components/Profil.tsx
index ee6c45b..fd1007b 100644
--- a/src/components/Profil.tsx
+++ b/src/components/Profil.tsx
@@ -58,7 +58,7 @@ function Profil()
{
setSuccessMsg('Daten geändert!');
setErrMsg("false");
- e.currentTarget.reset();
+ e.currentTarget?.reset();
}
else if(!data.success && data.message)
{
@@ -85,12 +85,13 @@ function Profil()
-
+
{successMsg !== "false" && {successMsg}
}
{errMsg !== "false" && {errMsg}
}
+ QR-Code drucken
)
}
diff --git a/src/components/Qr.tsx b/src/components/Qr.tsx
index 3d0bcef..d9413f7 100644
--- a/src/components/Qr.tsx
+++ b/src/components/Qr.tsx
@@ -1,4 +1,5 @@
import React, { useContext, useState } from 'react'
+import { Link } from 'react-router-dom';
import { UserCtx, UserCtxT, DogT, Axios, ResponseT, TUser } from '../context/UserContext';
import Img from './Img';
import './Qr.css';
@@ -27,6 +28,8 @@ export default function Qr()
{user && dog.data &&
Qr-Code Druck
+
Zurück zum Profil
+
{/*
Logged in als:
{user?.email}
{user?.qr_id}