Downloading a file via php page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

Downloading a file via php page

Post 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!
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post 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...
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Re: Downloading a file via php page

Post 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>
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

yeah, i actually fixed that part in the code i put up too but forgot to mention it.
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

Thank you very much

Post 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 :(
Post Reply