hi guys,
am testing this script, but its not working.
my requirements:
current file in database and in folder is 135.docx, and if i want to update it by uploading a new file, the new filename should be 135_1.docx , if update again it must be 135_2.docx and so on, the word file will just keep adding up in the folder but the database will just update its row data.
$infile = 135.docx
if ($pos = strrpos($infile, '.')) {
$name = substr($infile, 0, $pos);
$ext = substr($infile, $pos);
} else {
$name = $infile;
}
$testname = $name.$ext;
//$newpath = $target.'/'.$infile;
$newpath = $target.$infile;
$name_inc = $infile;
$counter = 1;
while (file_exists($newpath)) {
$name_inc = $name.'_'.$counter.".".$ext;
$newpath = $target.'/'.$name_inc;
$counter++;
}