this time we will make the auto rename action when you upload your file to a web, the point is file will continue in sequence based on ID, so we will easy when we want to find a file that we have uploaded.
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAagagfs8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crosorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-md-4">
<br/><br/><br/>
<form action="action.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<div class="form-group">
<p><h2><span class="label label-warning">SELECT PICTURE :</span> </h2><br/><br/><input type='file' name='filegbr' id='Filegambar'></p>
</div>
<div class="form-group">
<input type="submit" name="Submit" value="Upload" />
</div>
</form>
</div>
<div class="col-md-4"></div>
</div>
</body>
</html>
<body background="background.jpg">
the above code will display image like this
I will explain a bit of the script function above.
this is the script link for the design of our web page<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwegxhjVME1fgjWPGmkzs7" crosorigin="anonym">make sure you are online while running php file above.
then, this is the script that will take us to the action.php page when pressing the upload button.
<form action="action.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<body background="background.jpg">
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hghfhDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<?php
include "connect.php";
$namafile= $_FILES['filegbr']['name'];
{ $jenis_gambar=$_FILES['filegbr']['type'];
$namafolder="gambar/";
if (!empty($_FILES["filegbr"]["tmp_name"]))
if($jenis_gambar=="image/jpeg" || $jenis_image=="image/jpg" || $jenis_image=="image/gif" || $jenis_gambar=="image/png")
{ $lampiran = $foldername . databasename($namafile);
if (move_uploaded_file($_FILES['filegbr']['tmp_name'], $draft))
{$query_insert = "INSERT INTO datapic (img)
VALUES ('$filename')";
$insert = mysql_query($query_insert);
$data = "SELECT id,img from datapic order by id desc limit 1";
$bacadata = mysql_query($data);
$select_result = mysql_fetch_array($readdata);
$id = $select_result['id'];
$img = $select_result['img'];
if ($insert)
{
$updatename = "UPDATE datapic SET new_name = CONCAT(id, '-',img)";
$rename = mysql_query($update_name);
$dash = '-';
rename($draft,$foldername.$id.$dash.$img);}
else
echo"
image has been saved
FIRST NAME : $img
NEW NAME: $newname
";
} else {echo "image failed to upload";}
} else {echo "wrong format. Harus .jpg .gif .png";}
} else {echo "you not select iamge to upload";}
?>
</div></div></div></body></html>
<body background="background.jpg">
{$query_insert = "INSERT INTO datapic (img)
VALUES ('$namafile')";
$insert = mysql_query($query_insert);
$data = "SELECT id,img from datapic order by id desc limit 1";
$bacadata = mysql_query($data);
$select_result = mysql_fetch_array($bacadata);
$id = $select_result['id'];
$img = $select_result['img'];
$bacanm = "SELECT newname from datapic order by id desc limit 1";
$baca = mysql_query($bacanm);
$select_result = mysql_fetch_array($baca);
$newname = $select_result['newname'];
<?php
$host = "localhost";
$username = "root";
$password = "";
$databasename = "rename";
$connection = mysql_connect($host, $username, $password);
mysql_select_db($databasename, $connection) ;
?>
$databasename = "rename";THANK'S FOR VOTE, COMMENT, AND FOLLOW