Fix file upload error handling and update profile picture paths
This commit is contained in:
parent
035b2272aa
commit
ec53e202e1
12
upload.php
12
upload.php
@ -29,14 +29,12 @@ if (!isset($_FILES['uploadFile']) || !is_array($_FILES['uploadFile']))
|
||||
$file = $_FILES['uploadFile'];
|
||||
|
||||
$fileError = isset($file['error']) ? (int)$file['error'] : UPLOAD_ERR_NO_FILE;
|
||||
if ($fileError !== UPLOAD_ERR_OK) {
|
||||
echo "<pre>";
|
||||
var_dump($_FILES['uploadFile']);
|
||||
echo "</pre>";
|
||||
if ($fileError !== UPLOAD_ERR_OK)
|
||||
{
|
||||
header('Location: account.php?upload=err');
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Basic Validierung
|
||||
$tmp = isset($file['tmp_name']) ? (string)$file['tmp_name'] : '';
|
||||
if ($tmp === '' || !is_uploaded_file($tmp))
|
||||
@ -62,7 +60,7 @@ if (!$mime || !isset($allowedMimeToExt[$mime]))
|
||||
|
||||
$ext = $allowedMimeToExt[$mime];
|
||||
|
||||
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'profilePictures';
|
||||
$targetDir = '/FSST/Website/assets/images/profilePictures';
|
||||
if (!is_dir($targetDir))
|
||||
{
|
||||
@mkdir($targetDir, 0755, true);
|
||||
@ -81,7 +79,7 @@ if (!move_uploaded_file($tmp, $targetPath))
|
||||
}
|
||||
|
||||
// Pfad, der in HTML genutzt wird (relativ zur Webroot)
|
||||
$publicPath = 'assets/images/profilePictures/' . $filename;
|
||||
$publicPath = '/assets/images/profilePictures/' . $filename;
|
||||
|
||||
$servername = "localhost";
|
||||
$port = 3306;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user