-1
在将图像上传到我的数据库服务器之前,我将如何根据将其上传到base64字符串的用户的用户标识重命名图像。我将如何重命名base64图像
这里是我的PHP代码,
<?PHP
if(isset($_POST['image'])){
$now = DateTime::createFromFormat('U.u', microtime(true));
$id = $now->format('YmdHisu');
$upload_folder = "upload";
$path = "$upload_folder/$id.jpeg";
$image = $_POST['image'];
if(file_put_contents($path, base64_decode($image)) != false){
echo "upload_success";
exit;
}
else{
echo "upload_failed";
exit;
}
}
else{
echo"image_not_in";
exit;
}
?>
您需要通过用户ID作为一个参数或将其存储在会话时用户登录。 –