473,498 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to download a file??

Hello guys i'm new in this group but can you help me...i want to create
a "download files" system - something like "download.com" - but like
"download.com" i dont want the direct link to the file to show i want
it to be something like :

"http://www.myhomepage.com/getfile.php?id=132"

the idea is to optain the id through the "$_GET" and then get the path
of the file from the DB ...but then what?the "header()" function wont
work unless its the 1st function to be called so i cant query the DB
for the file path then call it!! or is there any other function i can
use to send the file to the user ???? can any one help me plzzzzzz it's
drivin me nuts... :))) thnx in advance...

Jul 17 '05 #1
9 1763
I noticed that Message-ID:
<11**********************@f14g2000cwb.googlegroups .com> from
th*****@gmail.com contained the following:

"http://www.myhomepage.com/getfile.php?id=132"

the idea is to optain the id through the "$_GET" and then get the path
of the file from the DB ...but then what?the "header()" function wont
work unless its the 1st function to be called so i cant query the DB
for the file path then call it!!

Yes you can. Just make sure you don't out put any html before you call
it
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
th*****@gmail.com wrote:
the idea is to optain the id through the "$_GET" and then get the path
of the file from the DB ...but then what?the "header()" function wont
work unless its the 1st function to be called so i cant query the DB
for the file path then call it!! or is there any other function i can
use to send the file to the user ???? can any one help me plzzzzzz
it's drivin me nuts... :))) thnx in advance...


You obviously have miss-interpreted the info on http://www.php.net/header.

You cannot call header after any output, but you can call as many functions
you like before calling header() as long as they do not produce any output.

So, the following will fail:

<?php
echo strtoupper("hello");
header("Location: http://www.google.com");
?>

And the following will succeed:

<?php
strtoupper("hello");
header("Location: http://www.google.com");
?>
JW


Jul 17 '05 #3
Thanx a lot guys for the clarification  I'll try it again and then
see what happens thanx a lot…

Jul 17 '05 #4
Ahhh...guys sorry to bother ya again.....but what prameters should i
use with the header so i can download a file...(i'm really a
newbie)...i thought of useing the "Location :" but i figured it only
for redirection to some other web site....

Jul 17 '05 #5
th*****@gmail.com wrote:
Ahhh...guys sorry to bother ya again.....but what prameters should i
use with the header so i can download a file...(i'm really a
newbie)...i thought of useing the "Location :" but i figured it only
for redirection to some other web site....


File name! Something to stop the file getting cached, assuming you don't
want that. The below code is what I use for RTF files when I generate them.
Note that there is a problem with Galeon and RTF, so there is a workround
included in the code. Note the comment above CSV is out of date!

Pete

//The output data is generated dynamically, we do not want an old copy stuck
in a cache.

//HTTP 1.1
header("Cache-control: no-store, no-cache, must-revalidate");

//HTTP 1.0
header("Pragma: no-cache");

//Output a csv file, text/plain for a simple plain text file.
header("Content-Type: application/rtf");

//Force browser to save it
//Does not work on Galeon so create a cludge
$user_agent = $_SERVER["HTTP_USER_AGENT"];
if ( $filename != null ) {
if ( !eregi("galeon",$user_agent) ) {
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
}
--
http://www.petezilla.co.uk
Jul 17 '05 #6
Hello!
$user_agent = $_SERVER["HTTP_USER_AGENT"];
if ( $filename != null ) {
if ( !eregi("galeon",$user_agent) ) {
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
}


I think the following code is a bit nicer to read:

<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];

if (($filename != null) || !eregi('galeon', $user_agent)) {
die();
}

header('Content-Disposition: attachment; filename="'.$filename.'"');
?>

Regards,
Hero Wanders
Jul 17 '05 #7
helloo many thanx for your replys but the problems still isnt solved
the problem is i want to duild a download system for "*.fla" files and
the file's full path is on the DB .. so what i'm tryin to do is to get
the fill path from the "$_GET[]" then get the fill path from the DB
then make the download process start at the client side...what
functions and how will i use them please help me!!! :)

Jul 17 '05 #8
th*****@gmail.com wrote:
helloo many thanx for your replys but the problems still isnt solved
the problem is i want to duild a download system for "*.fla" files and
the file's full path is on the DB .. so what i'm tryin to do is to get
the fill path from the "$_GET[]" then get the fill path from the DB
then make the download process start at the client side...what
functions and how will i use them please help me!!! :)


Ah, I think my post was halfway there. Maybe you could output the
appropriate content type header for your '.fla' file. Then read the file
in to a variable (read?) and then use echo to output it.

Pete

--
http://www.petezilla.co.uk
Jul 17 '05 #9
you know yesit worked thanx a lot man sorry for repeating the quistions
:)

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6078
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
0
1812
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
0
1724
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring,...
4
2311
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those...
1
3550
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
3
2119
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
16
3218
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
0
2148
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
0
3992
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
1
47344
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.