 |
Forum PHP Romania - Discutii despre PHP, MySQL, Javascript, AJAX, etc Comunitatea PHP Romania
|
| Subiectul anterior :: Subiectul următor |
| Autor |
Mesaj |
tepes
Data înscrierii: 03/Apr/2003
Mesaje: 58
|
| Trimis: Vin Oct 29, 2004 10:07 am Titlul subiectului: cum ascund un link de download? |
|
|
| Am nevoie de un script de download. Am 5 fisiere .zip in directorul download dar nu vreau sa dau link de genul site.com/download/fisier1.zip ci vreau ceva de genul site.com/download.php?file=fisier1 si sa imi porneasca downloadul. Stiu ca e ceva cu headere. Imi da si mie cineva un exemplu simplu? Sau un link pe net cu un tutorial? |
|
| Sus |
|
stealth
Data înscrierii: 21/Iun/2004
Mesaje: 304
Locație: Timisoara
|
| Trimis: Vin Oct 29, 2004 11:28 am Titlul subiectului: |
|
|
recomand alceva decat file=. de ex. download.php?fisier=1
pai in php poti sa ai ceva de genul:
switch ($_GET["fisier"]){
case 1:
header("Location: calea/catre/fisier");
break;
case 2:
header("Location: calea/catre/fisier2");
break;
case 2:
header("Location: calea/catre/fisier3");
break;
} |
|
| Sus |
|
un_guru
Data înscrierii: 25/Iul/2004
Mesaje: 153
Locație: Miecurea Ciuc
|
| Trimis: Vin Oct 29, 2004 1:30 pm Titlul subiectului: |
|
|
| an style="color: #000000"><?php if(isset($_REQUEST['download'])){
$request_file = _FILES_DIR_ . "/" . $_REQUEST['download'];
if(!file_exists($request_file)) {
echo "bau..$request_file";
die();
}
$file_size = filesize($request_file);
$ext=substr(strrchr($request_file, '.'), 1);
$mtype=$type[$ext];
header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Cache-control: private");
header("Content-Length: " . $file_size);
header("Content-Type: $mtype");
header("Content-Type: application/download");
if (preg_match('#Opera(/| )([0-9].[0-9]{1,2})#',getenv('HTTP_USER_AGENT')) or preg_match('#MSIE ([0-9].[0-9]{1,2})#', getenv('HTTP_USER_AGENT'))) {
header("Content-Type: application/octetstream");
} else {
header("Content-Type: application/octet-stream");
}
header( "Content-Disposition: filename=".$request_file.";");
}
// $mtype este un vector ['extensie'] => 'tip fisier'(string)
// utilizatre: download.php?download=fisier.zip |
|
| Sus |
|
PHPRomania Bot
Bot Member
Data înscrierii: 27/Dec/2007
Mesaje: 1
Locaţie: Server Google |
| Trimis: Mie Dec 26, 2007 7:01 pm Titlul subiectului: Ad |
|
|
|
|
|
| Sus |
|
| |
|