Write a file from blob to a specified directory

Hello…
I have a PDF in a blob, and I have to save it in a directory, and then send it by mail …
I managed to save it, but only in the download folder …
I can’t find the way to redirect it to some directory, from which it can then take the path to attach it.

sc_lookup(rs1,"Select Comprobante, NombreArchivo From Comprobantes Where Cod_Registro = " . [Cod_RegistroPar]. " AND Tipo = '".[TipoCptePar]."'");
if(count({rs1}) <> 0) {
	$filenombre = {rs1[0][1]};
	$ubot = {rs1[0][0]} ;
	
	$dir = $this->Ini->path_doc;
	$dir = $dir."/PDF";
	$arquivo = $dir."/".$filenombre;
	//header("Content-Description: File Transfer");
	//header("Expires: 0");
	header('Content-type: file/pdf');
	header("Content-Disposition: filename=".$arquivo);
	echo $ubot;
	sc_redir("Envio_Mail_Comprobante");
	exit();
}

Some help?
Thanks!!!