update lấy features từ ảnh upload

This commit is contained in:
2020-12-08 16:06:19 +07:00
parent 811ed32e04
commit f694e9fe71
5 changed files with 116 additions and 32 deletions

View File

@@ -8,6 +8,7 @@ use yii\filters\VerbFilter;
use yii\helpers\FileHelper;
use app\models\CaptureLogs;
use app\models\ListManagement;
use app\models\common;
/**
* CardController implements the CRUD actions for Card model.
@@ -58,7 +59,7 @@ class ApiController extends Controller {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->bodyParams;
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
$key = $this->generateRandomString();
$key = common::generateRandomString();
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
$targetPath = $RootFolder . "/face";
$fileName = "face_" . $key . "_" . $time . ".png";
@@ -95,14 +96,4 @@ class ApiController extends Controller {
return $allFeatures;
}
public function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
}