Right now the creator of this script is no longer updating it, and ive sent this request to him for a future feature.
But anyways what i want is it to check if the file exisits, if it does, to rename the file acordingly.
<?php
// CONFIG
$serverpath = "/home/ixthdcom/ixthd.com/uploads/images/"; // Path to where images should be uploaded to on the server. INCLUDE TRAILING SLASH.
$urltoimages = "http://img.gr4f.com"; // Web address to where the images are accessible from. INCLUDE TRAILING SLASH.
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='?x=upload&mode=upload'>\n";
echo "<input type='file' name='file'>\n";
echo "<input type='submit' name='Submit' value='Go'>\n";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "PNG";
$path = "$serverpath/$file";
foreach($allowedfiles as $allowedfile) {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
echo "<form enctype='multipart/form-data' method='post' action='?x=upload&mode=upload'>\n";
echo "<input type='file' name='file'>\n";
echo "<input type='submit' name='Submit' value='Go'>\n";
break;
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p><A href='$urltoimages/$file' target='_blank'><strong>$urltoimages/$file</strong></a></p>";
echo "<p><img src='$urltoimages/$file' border='0'>";
$img = "[img]$urltoimages/".$file."[/img]";
echo "<p><b>BBcode:</b><br> $img </p>";
break;
}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
?>