Use a form to download a file from a URL - SitePoint

DOWNLOAD LINK GATHER AT THE END OF THIS CONTENT

Here’s a website: Download link generator[2]

And here’s the form in the page source:

<form id="download" class="download_action" method="POST">
<input type="hidden" name="action" value="download_action">
<label for="url">Please enter the URL you would like to save as a file:</label>
<div class="field">
<input id="url" class="text mr-3" name="keyword" type="text">
<input class="submit" title="Save target as" type="submit" value="Save target as">
</div>
<div class="tool-target" style="padding-bottom: 10px;"> </div>
<div id="return"> </div>
<input type="hidden" id="_wpnonce" name="_wpnonce" value="5c9a47c6d6" /><input type="hidden" name="_wp_http_referer" value="/tools/download-link-generator" />
</form>

It seems to be a server-side solution, but I don’t have much information about servers and how they do it. I wonder how it works exactly. Can similar projects be built on GitHub Pages, or do I need paid hosting and a server plus a vast knowledge of running it?

Short hand?

Server receives form.
Server gets url.
Server probably checks some things.
Server gets file contents
Server sends appropriate header for “this is a download”
Server pastes file contents
Server sends to browser.

Why do this instead of just… going to the URL? shrug

References

  1. ^ Mori (www.sitepoint.com)
  2. ^ Download link generator (adresults.com)
Use a form to download a file from a URL - SitePoint

Total