简体   繁体   中英

Download pdf file, find from user name

can help download pdf file, i have code:

<?php echo '<a href="path/'.$_SESSION['user'].'.pdf">dowload pdf</a>'; ?>

'User' is 548754 , pdf file name is * 548754 *00_01215.pdf, how make download pdf file find by first 6 (six) number.

Thanks

If you would like to echo a link with the UserID in it, then add the rest of filename:

<?php echo '<a href="path/'.$_SESSION['user'].'00_01215.pdf">dowload pdf</a>'; ?>

However, if you want to find the PDF file(s) which begin with the user's ID, then do something like this:

<?php
$directory = opendir('./');
$userid = "548754";
  while ($file = readdir($directory)) {
    if($file!="." && $file!=".." && strpos($file,$userid) !== false){
      echo '<a href="'.$file.'">Download PDF</a><BR>';
    }
  }
closedir($directory);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM