在我的公共檔案夾中有一個 pdf 檔案夾,其中有很多 pdf。我在用
<a href="/pdf/1.pdf" download="1.pdf"> 1</a>
因此,當任何主體單擊 1 時,他們將能夠下載該檔案。我什至嘗試使用資產來做,但發生的問題是我可以在本地主機上下載但無法在實際服務器上下載。它顯示失敗-沒有檔案。有關更多資訊,我正在使用 Nginx。
server {
server_name xxx.xxx.com;
root /var/www/xxx.xxx.com/public;
index index.php;
location / {
try_files /index.php /index.php;
include snippets/fastcgi-notry-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
uj5u.com熱心網友回復:
正如您從配置中看到的,.css 和 .js 檔案擴展名有例外,它們作為具有適當內容型別的靜態檔案提供。這就是為什么您可以看到所有樣式和 js 代碼的原因。很明顯,您還必須添加將用作靜態檔案的檔案擴展名:
location ~ \.pdf {
add_header Content-Type application/pdf;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/382285.html
上一篇:從CSV讀取的奇怪問題
