I have the following PHP code from an HTML application (user is using Chrome browser on Android)
$path_full = '../files/this_is_my_dir/test.pdf';
$path_exploded = explode('/', $path_full);
$filename = end($path_exploded);
if (file_exists($path_full)) {
$finfo = new finfo(FILEINFO_MIME);
header('Content-Description: File Transfer');
header('Content-Type: ' . $finfo->file($path_full));
header("Content-Disposition:attachment;filename='" . $filename . "'");
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path_full));
readfile($path_full);
}
When a user clicks an icon it will force download (with above code) the file (which is outside public root) to the android download folder. But we want that the PDF automatically after download opens (just like click on a a href link). Is this possible ?