|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Content disposition
Hi
I've been trying to understand how to force a user to download a file. What i've done is save a bunch of rows from the DB into a variable called $data. From here, I tried to study how the header actually works. http://uk2.php.net/manual/en/function.header.php I'm adding these lines to the function.. so basically my function is now PHP Code:
But the browser doesnt seem to force the user to download it. I dont understand what it is that i'm doing wrong. Could someone please help? cheers! |
|
#2
|
|||
|
|||
|
What do you mean by 'force them to download it'? Do you want it to open the usual download options dialog when the page opens or just start downloading without consulting the user?
-KM- |
|
#3
|
|||
|
|||
|
http://us2.php.net/manual/en/function.header.php
Essentially, your header will look something like the following: Code:
header("Content-disposition: attachment; filename=/real/path/to/filename.sql");
header('Expires: Mon, 26 Nov 1962 00:00:00 GMT');
header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
header('Pragma: no-cache');
or for IE : Code:
header("Content-disposition: attachment; filename=/real/path/to/filename.sql");
header('Expires: Mon, 26 Nov 1962 00:00:00 GMT');
header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#4
|
|||
|
|||
|
Is the source you wrote laidbak have the effect of opening a "download window" and is this work for opening a file for download from FTP server?
Thanks, R. |
|
#5
|
||||
|
||||
|
Quote:
This is commonly used to serve a files that you would like to keep out of your document root. Quote:
If the ftp has password protection, and you are not willing to give up the username/password combo, then this is probably not the correct approach. |
|
#6
|
|||
|
|||
|
Well yes the FTP server has username and password but I pass them like this :
ftp://username:_password@ftp/some_folder/some_file.mp3 it this OK ? ![]() thanks |
|
#7
|
|||
|
|||
|
This is fine if you don't care that you are sharing your username/password with whomever.
|
|
#8
|
|||
|
|||
|
Quote:
FTP is insecure anyway, sending the username/password in plain text, it wouldn't be hard for some packet sniffer or whatever to grab the passwords.
__________________
http://www.phptutorials.cjb.net. go on, give it a click! |
|
#9
|
||||
|
||||
|
It's still much easier to get the username/password when its BLATANLY DISPLAYED IN THE URL... =)
|
|
#10
|
|||
|
|||
|
Quote:
Is true but there are many people who seem to think that protocols like FTP, POP, IMAP etc are secure! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Content disposition |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|