我创建此代码以保存照片并按月创建文件夹并将其保存到我的数据库mysql。
<?php
include 'connect.php';
$name = $_POST['name'];
$date1 = date('Ymd');
$month = date('Ymd');
$photo_file = 'photo/'.$month.'/'.$date1."".$name.".jpg";
echo $photo_file;
$encoded_data = $_POST['mydata'];
$binary_data = base64_decode( $encoded_data );
// save to server (beware of permissions)
if (!is_dir('photo/' . $month)) {
// dir doesn't exist, make it
mkdir('photo/' . $month);
}
$result = file_put_contents($photo_file, $binary_data);
$sql="INSERT INTO image (images) VALUES('$photo_file')";
$result=mysqli_query($con,$sql);
?>
问题是如何更新(替换为新的)当前保存照片?我应该用什么方法来更新它?