前端使用a
標籤下載圖片文件時由於瀏覽器機制問題致使會直接打開圖片連接進行預覽。
爲了方便,不須要後臺進行處理傳輸文件流返回。因此進行nginx配置,讓連接圖片在瀏覽器中直接下載html
server { listen 8086; server_name 192.168.1.66; location / { proxy_pass http://127.0.0.1:8086; root html; index index.html index.htm; } location /image/ { root html/devGif; autoindex on; // 主要配置 if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx|jpg|png)$){ add_header Content-Disposition 'attachment'; } //end } }