- 🇮🇩Indonesia tinohuda
I have drupal 9 webform and files element (private file system), if i access the file its always downloaded, when i use pdf.js its not loaded.
I've add header Content-Disposition: Inline in the nginx conf
# Handle PDFs to display inline location ~* \.pdf$ { add_header Content-Type application/pdf; add_header Content-Disposition "inline; filename=\"$uri\""; try_files $uri /index.php?$query_string; } # Private files handled by Drupal location /system/files/webform/ { internal; try_files $uri /index.php?$query_string; } # Custom handling for PDFs in private files location ~* ^/system/files/webform/.+\.pdf$ { types { application/pdf pdf; } add_header Content-Type application/pdf; add_header Content-Disposition "inline; filename=\"$uri\""; try_files $uri =404; }
Unfortunately the pdf still cannot open in the browser, its always downloaded.
I check in the Browser Header content Content-Disposition valeu is attachment.
But when i try to direct access via php it's work.
<?php header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="example.pdf"'); readfile('/system/files/webform/example.pdf');
Anyone can assist me how to make pdf in drupal private files can display in the browser, so I can display via pdf.js.
Thank you for help.