doufangzhang4454 2013-12-14 10:58
浏览 19
已采纳

下载pdf文件,从用户名中查找

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

  • 写回答

1条回答 默认 最新

  • duanli8577 2013-12-14 11:12
    关注

    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);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改