【发布时间】:2015-06-23 13:39:32
【问题描述】:
如何在插入数据库之前重命名图像文件?
- 数据库名称:项目
- 表格名称:图片
- 字段:id (
int)、文件 (varchar) [图片网址存储在这里]、名称 (varchar) [图片描述]
HTML 代码放在这里
<form method="POST" action="signup_process.php" enctype="multipart/form-data">
Image: <input type="file" name="user_image">
<input tyoe="submit" value="submit">
</form>
signup_process.php
<?php
include 'dbcon.php';
$filename = $_FILES[user_image][name];
$source = $_FILES[customer_photo][tmp_name];
$destination = "photos/$filename";
move_uploaded_file($source, $destination);
//sql statement bla bla below to upload file in image table
?>
此脚本将文件上传到我的服务器的照片目录中,但我想要的是我想将该名称更改为我的图像表的相应 id。 例如sunny.jpg --> 5.jpg
【问题讨论】:
-
脚本太长了……我需要修改我的代码。
-
没有人需要更改您的代码。您的问题已在该链接中得到解答。