upload php

This commit is contained in:
2023-01-03 18:20:56 +01:00
parent 875f0b87c4
commit 371b55bd64
5 changed files with 160 additions and 72 deletions

View File

@ -46,6 +46,23 @@ class CUser
$this->qr_id = $qr_id;
$this->email = $email;
}
function jsonarray()
{
return json_encode([
'id' => $this->id,
'qr_id' => $this->qr_id,
'email' => $this->email
]);
}
function phparray()
{
return ([
'id' => $this->id,
'qr_id' => $this->qr_id,
'email' => $this->email
]);
}
}
/**
@ -81,18 +98,26 @@ function random_str(
function getNewFilename($targetDir, $fileExt, $length)
{
$newFname = random_str($length);
// echo "newFname " . $newFname . "\n";
$maxtries = 100000; // prevent endless loop, most unlikely
$tries = 0;
// echo "file_exists " . $targetDir . '/' . $newFname . '.' . $fileExt . "\n";
// echo "file_exists " . file_exists($targetDir . '/' . $newFname . '.' . $fileExt) . "\n";
while(file_exists($targetDir . '/' . $newFname . '.' . $fileExt) && $tries < $maxtries)
{
// echo "file_exists " . $targetDir . '/' . $newFname . '.' . $fileExt . "\n";
++$tries;
$newFname = random_str($length);
// echo "tries " . $tries . "\n";
// echo "newFname " . $newFname . "\n";
}
if($tries < $maxtries)
if($tries >= $maxtries)
{
$newFname = "";
}
return $newFname;
return $newFname .".".$fileExt;
}
?>
?>