Okay so i have this script that will upload and remane the file to image.png which works perfect.
what i am trying to get is when uploaded number the image in order
image1.png
image2.png
image3.png
if (isset($_POST['submit'])) {
$newext = '.png';
$filename = $_FILES["file"]["name"];
$file_basename = substr($filename, 0, strripos($filename, '.')); // get file extention
$file_ext = substr($filename, strripos($filename, '.')); // get file name
$filesize = $_FILES["file"]["size"];
$allowed_file_types = array('.jpg','.png','.gif');
if (in_array($file_ext,$allowed_file_types) && ($filesize < 20000)) {
// rename file
$newfilename = image . $newext;
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename);
echo "File uploaded successfully.";
}
} elseif (empty($file_basename)) {
// file selection error
echo "Please select a file to upload.";
} elseif ($filesize > 20000) {
// file size error
echo "The file you are trying to upload is too large.";
} else {
// file type error
echo "Only these file typs are allowed for upload: " . implode(', ',$allowed_file_types);
unlink($_FILES["file"]["tmp_name"]);
}
}
thank you.