我试图在yii2中生成一个验证码,并在字符串数字中生成验证码.有什么办法吗?
我有问题要建立一个连接到DB的代码,然后关闭连接.
我的DB类如下:
class DataBase {
private $conn;
private $info;
private $db;
public function __construct ($servername=DB_SERVER, $user=DB_USER, $pass=DB_PASS, $db=DB_DATABASE) {
$this->db = $db;
$this->conn = new mysqli($servername,$user,$pass, $this->db);
if (!$this->conn)
{
if ($this->conn->connect_error) {
$this->info = "ERROR CODE=DB100: Connection failed <br> " . $conn->connect_error;
$this->close();
echo $this->getInfo();
}
else {
$this->info = "ERROR CODE=DB101: Connection failed <br> ";
$this->close();
echo $this->getInfo();
}
}
}
public function getInfo () {
return $this->info;
}
// send sql to database
public function sendQuery ($sql, …Run Code Online (Sandbox Code Playgroud) 我需要使用axios发送发帖请求,以便使用Filepond Uploader上传文件。
我该怎么做?
我正在使用如下所示的自定义流程处理程序,但无法正常工作。
processHandler: (fieldName, file, metadata, load, error, progress, abort) => {
let formData = new FormData();
let uploadPercentage = 0;
formData.append('file', file);
console.log(formData);
HTTP.post('v1/upload', formData,
{
headers: {
'Content-Type': 'multipart/form-data'
},
onUploadProgress: function (progressEvent) {
uploadPercentage = parseInt(Math.round((progressEvent.loaded * 100) / progressEvent.total));
console.log(uploadPercentage);
}.bind(this)
})
.then((response) => {
console.log(response);
// Should call the load method when done and pass the returned server file id
// the load method accepts either a string (id) or an object
// …Run Code Online (Sandbox Code Playgroud)