Im having a problem with this script
Code: Select all
$myFile = $dir.$names;
/**
while(file_exists($myFile))
{
$z = 1;
echo "The file ".$myFile." exists"."<BR>";
$myFile = $dir.$z.$names;
echo $myFile;
$z++;
}
**/
if (file_exists($myFile))
{
$z = 1;
echo "The file ".$myFile." exists"."<BR>";
$myFile = $dir.$z.$names;
} else
{
echo "The file ".$name." does not exist"."<BR>";
}Basically I want to add an integer to a file name if it already exists such as test.txt, 1test,txt, 2test.txt
Unforteiuntly, obviously the If statement will only change it once... while the While loop leaves me in a n infinite loop