1
I need to verify the existence of a file in two domains.
However, the file format that is saved in the database does not match the one saved on the server, due to a lag of a few seconds (the file name format is shown in the example below).
File that exists on the server https://www.dominio01.com.br/sistema/modulos/consultas/consulta_87314134987_02102017135619.pdf
File you are bringing https://www.dominio01.com.br/sistema/modulos/consultas/consulta_87314134987_02102017135613.pdf
As you can see, there is a difference in the last 2 characters (which represent the seconds... probably in the generation routine of this PDF, there is a delay of a few seconds that differs from the date recorded in the database).
$dir01 = "https://dominio01.com.br/sistema/modulos/consulta/consultas/";
$dir02 = "https://dominio02.com.br/sistema/modulos/consulta/consultas/";
$documento = preg_replace("/[^0-9]/", "", $item['retCNPJCPF']);
$dataDoc = new DateTime($item['retDataHora']);
$filename = "consulta_".$documento."_".$dataDoc->format('dmYHis').".pdf";
if(file_exists($dir01.$filename)){
$lnkConsultas = "Consulta disponível no dominio 01";
}
elseif(file_exists($dir02.$filename)){
$lnkConsultas = "Consulta disponível no domínio 02";
}
I wonder if it is possible to bring the files without the need to inform the seconds, and bring the occurrences of this... changing the filename, and searching through some regular expression. But I have no idea how to do it.
PS: I cannot use "glob". This will return blank results, because the files are in other domains.
I hadn’t read the "I can’t use it
glob
.". :(– Inkeliz
@Inkeliz unfortunately tried with glob, but the array returns blank :/
– Maykel Esser