Below are codes that I use to encode the file in base64_encode, Can I encode file base64_encode that expires..? Means the output file from base64 can viewed in a certain time and then expires.
$fileurl = "./$viewmgfoto";///url of my file from database
$imageData = base64_encode(file_get_contents($fileurl));
$finfo = new finfo();
$fileinfo = $finfo->file($fileurl, FILEINFO_MIME);
$src = 'data: '.$fileinfo.';base64,'.$imageData;
$src= str_replace(" ","",$src);
echo $src