How to rename the file of image before inserting into database?
- DB name :Project
- Table Name: image
- ields: id (
int
), file (varchar
) [image url stored here], name (varchar
) [image description]
HTML Codes GOES HERE
<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
?>
This script upload the file in photos directory of my seerver but what i want is i want to change that name to corresponding id of my image table . for example sunshine.jpg --> 5.jpg