After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 467 KiB |
After Width: | Height: | Size: 467 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 15 KiB |
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\gateway;
|
||||
class ImageSaver
|
||||
{
|
||||
|
||||
public static function getId() : int
|
||||
{
|
||||
return rand(10000,19999);
|
||||
}
|
||||
|
||||
public static function SaveImage(string $filename) : array
|
||||
{
|
||||
try {
|
||||
$return=[];
|
||||
|
||||
$name = substr($_FILES[$filename]["name"], 0, 45);
|
||||
$name = self::getId().$name;
|
||||
|
||||
move_uploaded_file($_FILES[$filename]['tmp_name'], "../public/uploads/$name");
|
||||
$return[]=true;
|
||||
$return[]=$name;
|
||||
return $return;
|
||||
} catch (\Exception $e) {
|
||||
$return[] = false;
|
||||
$return[] = "";
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|