Re: Routing downloads through PHP

From: Date: Tue, 14 Feb 2006 21:41:53 +0000
Subject: Re: Routing downloads through PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-230388@lists.php.net to get a copy of this message
Hi, Thanks for replying. Here's the code I put into download.php: ----------------- <? $fileid = $_GET['file_id']; $filearray = array( "a0"=>"data/download1.zip", "a1"=>"data/download2.zip"); $location = $filearray['a'.$fileid]; if($location!='') { header("LOCATION: $location"); } ?> ---------------- But when I send it: http://example.com/download.php?file_id=0 , I get the following error- Warning: Cannot modify header information - headers already sent by (output started at /public_html/download.php:6) in /public_html/download.php on line 18 Any idea what's going wrong? Thanks, J_K9 Russell Jones wrote:
<? $fileid = $_GET['file_id']; $filearray = array( "a0"=>"filename.zip", "a1"=>"filename2.zip", "a2"=>"filename3.zip"); $location = $filearray['a'.$fileid]; if($location!='') { header("LOCATION: $location"); } ?> ?>


« previous php.general (#230388) next »