when i upload image with same name it replace my precending imagage. I want to give him number (increment that number) 1_name.png, 2_name.png. This is my code:
if(isset($_POST['submit_im'])) {
$name = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
$location = 'uploads/';
$target = 'uploads/'.$name;
if(file_exists('uploads/'.$name)) {
$i = 1;
while(file_exists('uploads/'.$i."_".$name)) {
$i++;
}
$name = $i."_".$name;
}
if(move_uploaded_file($tmp_name,$location.$name)) {
$title = $_POST['title'];
$query = "INSERT INTO obrazky(img,title) VALUES ('".$target."','$title')";
$result = mysqli_query($connection, $query);
} else {
Thanks for help :)