upload php
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user