File Downloads

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Thu Mar 02, 2006 12:22 pm    Post subject: File Downloads Reply with quote

I have searched here and the PHP manual but haven't found what I want. I would like to be able to create a script that will control downloads (as in automatically start a download). I just need a hint about what functions are used to send a file - I want to create the script myself but just need a starting point.
_________________
Cheers.... Kev

Kev's Place - http://www.kevsplace.com

Powered by Abyss X1.
Back to top View user's profile Send private message Send e-mail Visit poster's website
dynaweb
-


Joined: 30 Apr 2003
Posts: 4

PostPosted: Thu Mar 02, 2006 3:40 pm    Post subject: Reply with quote

Your idea is expressed too vaguely IMO for someone to help you with this. You might want to expand a bit so we can realize exactly what you are wanting to do.
_________________
HostNed - ASP web hosting from only $25 a year! Where is YOUR site hosted?
Back to top View user's profile Send private message
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Thu Mar 02, 2006 7:37 pm    Post subject: Reply with quote

Sorry - I want to have a user click on a file download link that takes him/her to another page that that can have anything on it. On that page would also be a "file download will start shortly - if not click here" type message. The file download would then begin. Somwthing similar to using a meta refresh in HTML.
_________________
Cheers.... Kev

Kev's Place - http://www.kevsplace.com

Powered by Abyss X1.
Back to top View user's profile Send private message Send e-mail Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Mar 02, 2006 8:01 pm    Post subject: Reply with quote

You could make a php file that uses download.php?file=whatever.zip and then it displays the information for that file. Im sure there is a php script out there to do it or it shouldnt be too hard to make a custom one.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 02, 2006 8:01 pm    Post subject: Reply with quote

Why not just use a meta refresh then?
I don't see what's so hard about this.

Edit: Timing!
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Mar 02, 2006 8:06 pm    Post subject: Reply with quote

Very good timing!

The problem with a meta refresh is that there would have to be a seperate page for each file. With the PHP script there is one page and the file is passed through a form on the previous page to the file= part of the script.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 02, 2006 8:10 pm    Post subject: Reply with quote

I see.
Why not something as simple as:
Code:
<?php
if (!file_exists("files/".$_SERVER['QUERY_STRING']))
  echo "No such file.";
else
  echo "<a href='files/".$_SERVER['QUERY_STRING']."'>Download</a>, etc. etc.";
?>

And link to download.php?whatever.zip and put whatever.zip in files/?
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Thu Mar 02, 2006 8:35 pm    Post subject: Reply with quote

MN - I know how to get to the file (similar to what you have posted above) but the info I want is how to get PHP to actually send the file. I could use the META refresh method (from PHP) but I would like a more elegant way of doing it.
_________________
Cheers.... Kev

Kev's Place - http://www.kevsplace.com

Powered by Abyss X1.
Back to top View user's profile Send private message Send e-mail Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Mar 02, 2006 8:42 pm    Post subject: Reply with quote

PHP doesnt send files, the web server does. PHP simply points the browser to the location of the file.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 02, 2006 8:43 pm    Post subject: Reply with quote

http://www.php.net/manual/en/function.readfile.php

Edit: Your timing is impeccable.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group