GET File extension on php

313 Views Asked by At

i have 2 fields on my project to upload documents(pdf, words) i use the following code to get the file extension on upload and rename the file with my custom name:

$ext= pathinfo($rsnew["File"], PATHINFO_EXTENSION);

my problem that i need to add to this code that, if one of the field if not update with a new document then it use the current extension of the oldrecord that was previous upload, and no change to blank extension

any idea, thanks in advance

using this code but no working

$ext= pathinfo($rsnew["File"], PATHINFO_EXTENSION);
$ext2= pathinfo($rsold["File"], PATHINFO_EXTENSION);
 // $trim = substr($docpath,0,4);// not using now

if($_FILES["File"]["size"]  == 0) {
 $rsnew["File"] = "$rname $docpath1 $docpath2 " . " " . "$docpath ID$randomNumber" . ".$ext2";

    
} else {
  $rnew["File"] = "$rname $docpath1 $docpath2 " . " " . "$docpath ID$randomNumber" . ".$ext";
    return TRUE;
}

}
0

There are 0 best solutions below