Use readfile instead, its faster. Instead of using a PHP script, to read and flush the file, it's more neat to rewrite the header using. This will keep a "nice" URL myfile. To make this more robust you could add HTML5 feature detection and if it's not there then use window. Here's a different approach. I prefer rather than to rely on browser support, or address this at the application layer, to use web server logic.
If you are using Apache, and can put an. Of course, you could put this in httpd. The FilesMatch directive is just a regex so it could be set as granularly as you want, or you could add in other extensions. The Header line does the same thing as the first line in the PHP scripts above. If you need to set the Content-Type lines as well, you could do so in the same manner, but I haven't found that necessary.
For more information click here. In a Ruby on Rails application especially with something like the Prawn gem and the Prawnto Rails plugin , you can accomplish this a little more simply than a full on script like the previous PHP example. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Ask Question. Asked 12 years, 11 months ago.
Active 1 year ago. Viewed k times. If the Adobe Acrobat is not installed then it pop-up to the user for Downloading the file. Please tell me how i can do this? Rob W k 76 76 gold badges silver badges bronze badges. Prashant Prashant Add a comment. Active Oldest Votes. Martin Gottweis 2, 11 11 silver badges 26 26 bronze badges. This is a simple solution but unfortunately not very widely supported, esp.
Yep, I know right. That's why I have the side-note on compatibility. And according to your source both IE and Safari don't support this approach, or at least not yet : Anyhow, if you want all browsers to force download I suggest checking some of the other answers instead The solution is easy but unfortunately not supported in IE and Safari.
Instead of linking to the. TravisO TravisO 9, 4 4 gold badges 34 34 silver badges 44 44 bronze badges. Please don't make up headers and send them. Could you update your answer. Be careful when using this code verbatim, though. This code is likely dangerous in another way. Could be used by an attacker to attempt to scan your internal network for exposed PDF files.
Not to mention how easy it would be to bypass any "sanity checks" you think you'll be doing to the "file" parameter. Show 8 more comments. Alex V Alex V Pomster Pomster Add a comment. Active Oldest Votes. Windle Windle 1, 1 1 gold badge 13 13 silver badges 30 30 bronze badges. I tried this and it create a underlined peace of text saying Link to pdf in blue, so it looked like a link but did not do anything when i clicked on it, see my edit to see the file path im trying to connect to — Pomster.
Pommy Added a bit about how to use the full path you gave. No biggie Community Bot 1 1 1 silver badge. Cynthia Cynthia 4, 13 13 gold badges 39 39 silver badges 69 69 bronze badges. Ok Thanks that's helps me alot, The website is not live, but when it is there will be a temp file that i want to grab the pdfs out of, is that possible? Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Podcast what if you could invest in your favorite developer? Who owns this outage? Building intelligent escalation chains for modern SRE. Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Visit chat. Linked 1.
Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.
0コメント