Download a file when a page loads 2018
Active Oldest Votes. TransmitFile filePath ;. Improve this answer. VinayC VinayC Hi Vinay, when downloaded complete i want to close my application or webform — Surya sasidhar. Surya, unfortunately, that's not possible. Due to security implications, browsers does not allow to close any window via script that has not be opened by script. From better user experience perspective, when your user clicks on the link, it should open download page with some friendly message and using java-script, it should redirect the page to actual download url.
The download url should use content-disposition as inline - for files such as pdf, html, doc etc, browsers are likely to open in same window instead of downloading to disk.
Once read, user can close the window — VinayC. Waqas Waqas 6, 2 2 gold badges 28 28 silver badges 43 43 bronze badges. 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 behaviour you described happens if the PHP interpreter on the server hosting your website is offline.
If that happens again, you should contact your hosting support. The problem persisted after your feedback, until I cleared the browsing data. Had to do this on both devices used for testing, but everything is fine now.
Have you taken the WordPress Survey yet? Search WordPress. Skip to content. Download ES-Spain. Download SE-Sweden. Download CH-Switzerland. Download UK-United Kingdom. Download US-United States. Download NA-North America. Download RU-Russia. Download W1. Download CSY-Czech. Download DAN-Danish. Download DEU-German. Download ESP-Spanish.
Download FIN-Finnish. Download FRA-French. Download ISL-Icelandic. Download ITA-Italian. Download NLD-Dutch.
Download NOR-Norwegian.