Php redirect is trying to download file






















You create a new page, for example, called download. I could write a whole selector script with security checks etc, but that's outside of the scope of this question and would be more suitable on Stack Overflow too.

Note, writing a new header requires that there was no previous output by the script, otherwise any output will write a standard header to the page and the header command won't work.

HTML would require a page for each file, and tags to redirect to the download. This would mean that the url would change, but files can be controlled through those pages. Also, htaccess can do everything without a php script too, but again, not sure if you are using Apache. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. That template or WordPress page will read the query string coming in, then redirect the submitter to the proper file.

The PHP template can be created to send headers that force the browser to download the proper file. You would have to build the php template and read the incoming value, but other than that, sending the headers to the browser is not too hard.

If you don't mind having them click, your could put links to the downloadable files right in the displayed confirmation as well, but that's one additional step for them.

I know this question has been asked many times before but I can't find an answer to suit my needs. I need to find a way to force the download of a file and then, after the download has started, redirect to a "thanks for downloading" page.

It's important to hide the download file's location otherwise I would have just created an HTML link to the file. I obviously can't put a redirect header below the other headers as it just won't work. I can't really see where to go from here apart from opening this in a pop-up and directing the main window to the "thank you" page - but that is a LAST resort.

There really isn't much choice. If your primary goal is to hide the URL, that's a lost cause anyway. For good usability, you usually include the plain link on the page anyway "Download doesn't start? Click here You could try multi-part HTTP responses as suggested by netcoder, but I'm not really sure how well that's supported. The way things usually work with this restriction is like this:. You can make the download location for the file be a script that only returns the file if the user is allowed to download the file.

You can pass some temporary token between the "Thank you" page and the file download page to verify that the download is allowed. Something like that:.

In your case, you could just output the "Thanks for downloading" page content instead of the JavaScript redirect. Ok, first thing first, the browser need to know the file location to download it.

Anyone opening a standard browser dev tool like Firebug will be able to see in plain text the URL of your file. Now, I suppose you want to protect your file from unauthorised download. If that is what you want, there is a way for that using session. On your first page, you will put your code to check if the download is authorized. Page Web. SelectRows "Expanded Children", each [Children. Is that the sort of thing you're after? Message 4 of 6. In response to Anonymous.

Message 5 of 6. Message 6 of 6. Post Reply. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Is it possible to redirect after "pushing" a file to the user?

Ask Question. Asked 10 years, 8 months ago. Active 7 years, 2 months ago. Viewed 14k times. Improve this question. Blake Senftner Blake Senftner 1, 2 2 gold badges 13 13 silver badges 17 17 bronze badges.



0コメント

  • 1000 / 1000