【问题标题】:download link for files stored on a website without DNS entry ( local host files )存储在没有 DNS 条目的网站上的文件的下载链接(本地主机文件)
【发布时间】:2019-10-02 13:32:34
【问题描述】:

我正在开发一个还没有 DNS RR 的站点。

我已经修改了 Windows 主机文件,以便可以使用它。

点击链接时文件没有下载正常吗?

<a href="http://mathieu-icstar.dev.univ-amu.fr/system/files/2019-10/SUFLE-emplois_du_temps_240919.pdf" type="application/pdf; length=919827" target="_blank">SUFLE-emplois_du_temps_240919.pdf</a>

在新窗口上复制href 时有效。

【问题讨论】:

  • 不,不正常。查看浏览器开发者工具中的网络选项卡并查找错误。
  • 我有来自手风琴结构的嵌套链接,所以一定是这样。谢谢帮我排除这种可能性

标签: html file host


【解决方案1】:

如果您不使用任何框架来制作网站,那么只需为您的公共路径使用一个变量,而不是提供资源或链接的相对路径。

constant.php

<?php 
  define("PUBLIC_PATH", strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'.$_SERVER['SERVER_NAME'].str_replace($_SERVER['DOCUMENT_ROOT'], '', str_replace('\\', '/', dirname(__DIR__))).'/');     

?>

index.php

 <?php
     include "constant.php";
 ?>
 <a href="<?= PUBLIC_PATH ?>system/files/2019-10/SUFLE-emplois_du_temps_240919.pdf" type="application/pdf; length=919827" target="_blank">SUFLE-emplois_du_temps_240919.pdf</a>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-29
    • 2015-03-17
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    • 2018-01-14
    相关资源
    最近更新 更多