我希望在上传前重新映像重命名,并且应该使用PHP将重命名的图像名称插入到数据库中。我正在使用以下代码上传图像并将其他一些数据插入到数据库中。请帮助我重新命名图片,因为我初学PHP。在上传前重命名图像,并在PHP数据库中插入名称
<?php
if(isset($_POST['submit'])) {
$post_image = $_FILES['post_image']['name'];
$post_image_tmp = $_FILES['post_image']['tmp_name'];
$post_content = $_POST['post_content'];
if ($post_image=='' OR $post_content=='') {
echo "<script>alert('Fiil In All Fields')</script>";
} else {
move_uploaded_file($post_image_tmp, "../post_imgs/$post_image");
$insert_post ="INSERT INTO posts(post_image,post_content)values('$post_image','$post_content')";
$run_post= mysql_query($insert_post);
echo "<script>alert('Post has been Published Now...')</script>";
echo "<script>window.open('index.php?insert_post=insert','_self')</script>";
}
}
?>
请在每一行的前面使用4位编辑代码。这种形式是不可读的。 –