I want to make a php script that when the images folder has 30 images the next one uploaded becomes 1.JPEG and the rest go up one but the image which was 30.JPEG gets deleted because there is a 30 image limit. Would this even be possible to do? This is what I have tried so far but it gives a unexpected ";" error
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("jpeg","jpg","png");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152) {
$errors[]='File size must be excately 2 MB';
}
for ($file_tmp = 29; $i > 0; $i--)
for ($i = 29; $i > 0; $i--)
{
if (file_exists($file_tmp.".jpg");
rename($file_tmp.".jpg",($file_tmp+1).".jpg");
}
if(empty($errors)==true) {
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>