(Sorry if this is a really dumb question - I have done virtually nothing with PHP so still struggling to get to grips with the basics)
On one of my websites, I have non-web (.gpx) files available for download. At the moment, I just have links to those files in the HTML, but that isn’t ideal.
What I would like to have is a gateway page that gives instructions on how to download and use the files, and a brief disclaimer as well. But I don’t want to have to code up a gateway page for each and every download. What I would love to be able to do is something like:
taking you to a gateway page “downloadgpx.php”, which has the generic blurb about downloading the files, and then uses the query in the URL to generate a link to
<a href=“/downloads/route1.gpx”>.
My question is … how to I go about generating the link in this way?
For not display the gateway of file.
Just use this code:----
<form action=“download.php” name=“myform” method=“post”>
<input type=“hidden” name=“f” value=“file name to be download”>
<a href=“javascript: submitform()” style=“font-size:20px; color:#BB4B2B; text-decoration:none”><strong>Click here to download the ebook</strong></a>
</form>[URL=“http://www.phpkolkata.com”]
yep :agree: adding dirname() to the validation is even better but, not being a systems admin. guy, I would expect other system security/permissions to stop people linking to those type of directories.
Imho you should validate all inputs into a script just in case someone is trying to hack into the script for whatever reason.
In this case I would just make sure the file exists before displaying the download link. If someone tried to manipulate the value of $_GET[‘file’] then most probably the file will not exist and the link will not be displayed.
Otherwise it could be possible, albeit remote, that someone could cause the link to point to an unintended location.