Page 1 of 1

Downloading a file via php page

Posted: Tue Jun 25, 2002 1:44 pm
by conthox
Hello everybody!

I'm a beginner, (and I don't write good English too,..) and I got one question.

I have a couple of files on my homepage, available for download, and I want them to be downloaded via a page called download.php. I want to be able to do links like this:

Code: Select all

www.mysite.com/download.php?file=filename.zip
This adress will send you to the page download.php and at the download page you will find information and a download-link to the file filename.zip

I've tried this code, but it didn't work. Something wrong?

Code: Select all

<?php
if ($fil == "") &#123;
echo "A error message!";
&#125; else &#123;
echo "Dwld the file by a click at this <a href="" $fil "">LINK</a>";
&#125;
?>
Thank you for taking time reading and (maybe) give me a answer!

Posted: Tue Jun 25, 2002 2:26 pm
by kaizix
in this...

http://www.mysite.com/download.php?file=filename.zip

you have file

but in the code, you're using the variable $fil it should be $file so...

Code: Select all

<?php 
if ($file == "") &#123; 
echo "An error message!"; 
&#125; else &#123; 
echo "Dwld the file by a click at this <a href="$file">LINK</a>"; 
&#125; 
?>
although it may just be a typo in here...

Re: Downloading a file via php page

Posted: Tue Jun 25, 2002 2:31 pm
by protokol
conthox wrote:

Code: Select all

<a href="" $fil "">LINK</a>";
Also, you have too many " .. make it

Code: Select all

<a href="$file">LINK</a>

Posted: Tue Jun 25, 2002 2:41 pm
by kaizix
yeah, i actually fixed that part in the code i put up too but forgot to mention it.

Thank you very much

Posted: Wed Jun 26, 2002 1:04 pm
by conthox
Thank you very much :D

I think I get it.

Right now I'm trying to get my IIS working again. I updated it via Microsoft Windows Update, but that was a misstake,..

It started to hang and crash, I reinstalled it, but it don't want to function.

Maybe I have to reinstall Windows,. I hope not, but I maybe have to :(