• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Download PHP Page...

xzx

b&
b&
What i need is fairly simple.
I to make a link, that i can change the number, like 235, 236, etc...
and when someone clicks on the link, a small popup comes up and it will have a link to download the file, with that filenumber. I will add a banner to the page also, but it will be quite a few banners of small size.

Can anyone help?
 
Originally posted by hohoho
so you want to hide the path/name of the file ?

Yes, that also, but what i really need is to be able to click on a link, that passes two variable, the file name and extension, to a another page (pop-up, which i can do) and on that page it will have a link with the passed varibles from the link....
 
PHP:
$t = $QUERY_STRING;

if ($t == "1") {
header("Location: url.whatever");
} elseif ($t == "2") {
header("Location: url.whatever");
} elseif ($t == "3") {
header("Location: url.whatever");
}

// and on and on.......

That would be the manual way to do it. I suppose you could have a database if you want this to be huge (ie a lot of links).

But that should be up to par
 
What i need is:

I make a link like:

<a href="http://www.mysite.com/download.php?name=dbz&ext=exe">DBZ</a>

and what it does is passes those numbers in the variables name and ext, to another page, a popup, and on the popup it needs to provide a link to the file that i want.

Ex: the page will create a link to:

name ext
http://www.mysite.com/media/download/dbz.exe


Anyone know what code i need to use?
 
a link like ... http://www.mysite.com/download.php?name=dbz&ext=exe ... passes those ... variables ... to ... a popup [that will] provide a link ... http://www.mysite.com/media/download/dbz.exe
For the popup you'll need JavaScript, and since nothing you've mentioned requires anything server-side, why not do it all in JavaScript?

Put this in the <head></head> area of your downloads page:
Code:
<script langauge="Jav[b][/b]aSc[b][/b]ript" type="text/jav[b][/b]asc[b][/b]ript"><!--
function downloadPopup(filename,fileext){
	var downloadWindow=window.open("","downloadWindow","width=300,height=150");
	downloadWindow.document.write("<a href=\"http://url/to/files/"+filename+"."+fileext+"\">Download "+filename+"."+fileext+"</a>");
	downloadWindow.document.close();
}
//--></script>
Replace "http://url/to/files/" with the URL to where your downloads are and change the popup attributes to whatever you like.

Then make each download link like this:

<a href="javascript:void(0);" onClick="downloadPopup('name','ext');return false;">Download name</a>

...replacing "name" with the filename and "ext" with the file's extension. Instead of "javascript:void(0);" for the HREF you could put the real download URL there, that way browsers with JavaScript disabled will still be able to use the site (browsers with it enabled will be unaffected, since control is never returned back to the link after the popup).
 
Originally posted by Dusty
For the popup you'll need JavaScript, and since nothing you've mentioned requires anything server-side, why not do it all in JavaScript?

Put this in the <head></head> area of your downloads page:
Code:
<script langauge="Jav[b][/b]aSc[b][/b]ript" type="text/jav[b][/b]asc[b][/b]ript"><!--
function downloadPopup(filename,fileext){
	var downloadWindow=window.open("","downloadWindow","width=300,height=150");
	downloadWindow.document.write("<a href=\"http://url/to/files/"+filename+"."+fileext+"\">Download "+filename+"."+fileext+"</a>");
	downloadWindow.document.close();
}
//--></script>
Replace "http://url/to/files/" with the URL to where your downloads are and change the popup attributes to whatever you like.

Then make each download link like this:

<a href="javascript:void(0);" onClick="downloadPopup('name','ext');return false;">Download name</a>

...replacing "name" with the filename and "ext" with the file's extension. Instead of "javascript:void(0);" for the HREF you could put the real download URL there, that way browsers with JavaScript disabled will still be able to use the site (browsers with it enabled will be unaffected, since control is never returned back to the link after the popup).

That would work, and looks like what i need, but i really hate javascripts and i try to minimize use of them as much as possible.

I have a download manager, like anti-leech in php, and i wanted to integrate the two. I know that there is a really easy way to do what i need, i just don't know much php to really code it, i tried but only got errors.
 
in php...
PHP:
<?php
$filedir = "http://www.yoursite.com/files";
$n = "$filedir/${name}.$ext";
header("Location: $n");
?>
 
Back
Top